Jump to content
IGNORED

FastBasic draw text on graphics 8


Recommended Posts

On Mapping the Atari there's this Atari Basic code to draw text on a graphics 8 screen.

Could it be converted to FastBasic?

Could there be something faster?

Thanks!

 

Mapping The Atari - BITMAP8.basMapping The Atari - BITMAP8.txt

 

1 GRAPHICS 8
5 DLIST=PEEK(560)+PEEK(561)*256
6 LOBYTE=DLIST+4:HIBYTE=DLIST+5
7 REAL=PEEK(LOBYTE)+PEEK(HIBYTE)*256:SCREEN=REAL:TV=SCREEN
10 CHBASE=57344
20 DIM A$(128),BYTE(128),WANT(128)
27 PRINT "INPUT A 40 CHARACTER STRING:"
30 INPUT A$
35 TIME=TIME+1
40 FOR LOOK=1 TO LEN(A$)
50 BYTE(LOOK)=ASC(A$(LOOK,LOOK))
51 IF BYTE(LOOK)>127 THEN BYTE(LOOK)=BYTE(LOOK)-128
52 IF BYTE(LOOK)<32 THEN BYTE(LOOK)=BVTE(LOOK)+64:GOTO 55
53 IF BYTE(LOOK)<97 THEN BYTE(LOOK)=BYTE(LOOK)-32
55 NEXT LOOK
59 FOR EXTRA=0 TO 7
60 FOR LOOK=1 TO LEN(A$)
70 WANT(LOOK)=PEEK(CHBASE+EXTRA+BYTE(LOOK)*8)
80 POKE TV+EXTRA,WANT(LOOK):TV=TV+1
82 NEXT LOOK
85 SCREEN=SCREEN+39:TV=SCREEN
90 NEXT EXTRA
100 SCREEN=REAL+TIME*320
110 IF SCREEN>REAL+6080 THEN TIME=0:GOTO 100
120 GOTO 30

 

Link to comment
Share on other sites

You'll never really render text to bitmap very fast in Basic, even compiled.

That code looks really inefficient, it's calculating things like character bitmap for every scanline and also doing Ascii to internal character translation.  Also no stacked lines.

It could be sped up fairly easily.  With a bit more effort, ie write most of it in assembler, it could be much more usable.

  • Like 1
Link to comment
Share on other sites

Try this, just a quick conversion to cc65, not done any real conversion to make it faster, tried to keep as

close to the original code just for fun, sure it could be a lot quicker with a little work.

 

Here's the code, warts and all :)

 

 

#include <stdlib.h>
#include <string.h>
#include <errno.h>
// #include <conio.h>
#include <peekpoke.h>
#include <stdio.h>
#include <atari.h>
// #include <atarisyseq.h>
char *dlist;
int lobyte,hibyte;
int real,screen,tv;
char *chbase;
char A[128],byte[128],want[128];
int time=0;

int    main(void)
{
    char look,extra;
    _graphics(8);
    dlist=(char *)(PEEK(560)+PEEK(561)*256);
    lobyte=(int)dlist+4;
    hibyte=(int)dlist+5;
    real=PEEK(lobyte)+PEEK(hibyte)*256;
    screen=real;
    tv=screen;
    chbase=(char *)0xe000;
    do
    {
        printf("Input a 40 Character String\n");
        scanf("%s",&A);
        time=time+1;
        for(look=0;look<strlen(A)+1;look++)
        {
            byte[look]=A[look];
            if(byte[look]>127)
                byte[look]=byte[look]-127;
            if(byte[look]<32)
                byte[look]=byte[look]+64;
            if(byte[look]<97)
                byte[look]=byte[look]-32;
        }
        for(extra=0;extra<8;extra++)
        {
            for(look=0;look<strlen(A)+1;look++)
            {
                want[look]=PEEK(chbase+extra+byte[look]*8);
                POKE(tv+extra,want[look]);
                tv++;
            }
            screen=screen+39;
            tv=screen;
        }            
        
        do
        {
            screen=real+time*320;
        }
        while(screen>real+6080);
            time=0;


    }while(1);
 

temp1.xex

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Hi!

5 hours ago, Philsan said:

On Mapping the Atari there's this Atari Basic code to draw text on a graphics 8 screen.

Could it be converted to FastBasic?

Could there be something faster?

 

Here I published a simple implementation of the "TEXT" command in Fast Basic, you can use it in your code:

 

Have Fun!

 

 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Philsan said:

Could there be something faster?

In Compute's 1st Book of Atari Graphics, there's a machine language routine for text in graphics 8 (by Douglas Crockford).

The routine is on the first side of the disk (in both list and tokenized form). The filename is "P048L1"; the 48 stands for pg. 48, which

is where the listing appears in the book.

 

Edited by MrFish
  • Like 4
Link to comment
Share on other sites

1 hour ago, MrFish said:

In Compute's 1st Book of Atari Graphics, there's a machine language routine for text in graphics 8 (by Douglas Crockford).

The routine is on the first side of the disk (in both list and tokenized form). The filename is "P048L1"; the 48 stands for pg. 48, which

is where the listing appears in the book.

Here's a commented disassembly of the routine, by @kenjennings

 

Mixing Graphics 0 & 8 (Compute).asm

 

  • Like 2
Link to comment
Share on other sites

3 hours ago, MrFish said:

There's also J.D. Casten's 80-column routine for BASIC.

Easy 80.pdf 22.12 kB · 2 downloads

 

easy80.bas 4.1 kB · 2 downloads

 

 

Sorry, I didn't look at exactly what I posted here before doing so. What I posted was a version of the program that I altered to read the 80-column character set off the "H:" drive (for Altirra); and then I forgot to post the character set too. So, here's the original (unaltered version) and the set.

 

easy80.bas

 

column80.set

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...