Jump to content
IGNORED

8-Bit programming...


Inky

Recommended Posts

I plugged my 8-bit into my TV and enjoyed some Missle Command addiction last night, and then afterwards, I mucked around with the basic examples in the 600 XL user guide. Got me to thinking about trying to do some basic programs for the 8-bit. First, how good is the 8-bit basic? Secondly, is there any 8-bit programming guides on the web?

 

I'm thinking of starting on the 800win EMU first (as I have no storage devices for the actual computer as of yet)

Link to comment
Share on other sites

Oooo... another fledgling A8 coder? :)

 

   -Bry

 

Well, I piddled around with programming on the Coleco ADAM years ago, and since I can't hook that up (Man that thing is a monster!), I decided to try out my hand on the 8-bit to see what I can do.

Link to comment
Share on other sites

Atari BASIC is one of the best BASICs of its era, because it actually tells you about syntax errors as the code is entered, not at runtime. The biggest gotcha is that it doesn't handle strings like most other BASICs. You don't get multidimensional strings, but you do get massive flat strings that can be as large as memory.

 

And when it comes to machine language integration, Atari BASIC is first rate. You can call whatever address you want, and pass a list of parameters directly to the ML program.

Link to comment
Share on other sites

You can do some decent stuff in basic (I wrote a bunch of crap a long time ago) - but ultimately you're going to need a ML routine or two to make things work (like moving your PMG's up and down

No, there is a Basic way around that (using speedy strings to handle your PM). Then if you want your character to move, it's as easy as P0$(Y0,Y0+10)=SHIP$

 

The biggest gotcha is that it doesn't handle strings like most other BASICs. You don't get multidimensional strings, but you do get massive flat strings that can be as large as memory.

That aspect is one of the good points about Atari Basic, since you are able to use strings to hold things other than simple text...like machine language routines...X=USR(ADR$("hhh*...etc.

Link to comment
Share on other sites

Atari 8-bit BASIC was quite good for its time. It was interpretive, it ran at a respectible speed, it was, as has already been said, great at incorporating assembler routines, and it flowed quite logically. I wrote quite a few things in it before moving on to TurboBASIC and, ultimately, assembler with Mac/65.

 

There are plenty of resources around to learn it, so that shouldn't be a problem. Overall it's fun to fiddle with and can even do some pretty decent things. Heck, some of my favourite A8 games were BASIC or BASIC/assembler hybrid typins from Antic and Analog. :-)

Link to comment
Share on other sites

Some commercial programs were also programmed in Basic (like Temple Of Apshai & Mar Tesoro...both discussed in earlier threads)...so you can easily make custom levels and things for them.

Here's a little "Hack-o-matic"-type program that I wrote in Basic way back in the day. When it runs, it will ask you for a sector number on the disk and if it's a "boot" file (i.e. if all the sectors are sequential and not using sector links...generally if you can pull up a directory on the disk, it usually uses the sector links). After you answer those prompts, the program will begin displaying the data on the disk...scrolling though line-by-line, sector-by-sector. The sector that is currently being read will be displayed as "player" data to the left...as well as the bit pattern for each byte, the decimal value, the Atascii character, POKE character, Inverse Atascii, and a custom character value (which you can change in the string AL$), the sector number and it's offset in decimal, and the player data for the sector previously read. If you are holding down Paddle(2)'s trigger, the sectors will be read thru more quickly...as player data only (turning the knob will change the speed). Hitting the L key will bring you back to the first prompt (just in case you overshoot the sector you want to change). Any other key will halt the scrolling, and allow you to alter the bit pattern for the lines currently detailed using the joystick in the first port. Once a bit pattern is altered from the original, a circle will appear next to it's line. To resume scrolling, press the start key if you DO NOT wish to write the changes (in case you made a mistake), or the option key if you wish to write the changes. Take care and only work with backups, because the program has no "undo" function...and you could easily wreck the disk being read ;) The program contains examples of reading/writing to the SIO, and using strings to manipulate P/M data.

 

(cut'n'paste to your H: folder...ENTER"H6:filename.txt" to load it up in Atari800Win)

1 GRAPHICS 0:POKE 710,0:POKE 709,15:POKE 752,1

2 DIM A$(1),B$((((INT(ADR(A$)/1024)+1.5)*1024)-ADR(A$))-5),BUF2$(128),BUF$(128):SCREEN=PEEK(88)+256*PEEK(89)

3 DIM BYTE$(2048),BIT(7),VL$(3),SEC$(4),OFF$(3),SCRN$(24),SCR$(24),N$(81),AL$(256),BL$(1)

4 START=(ADR(BUF2$)-512)/256:POKE 559,0

5 AL$=CHR$(0):AL$(256)=AL$:AL$(2)=AL$:BUF$=AL$:BUF2$=AL$

6 BYTE$=CHR$(32):BYTE$(1024)=BYTE$:BYTE$(2)=BYTE$

7 BYTE$(1025)=CHR$(160):BYTE$(2048)=BYTE$(1025):BYTE$(1026)=BYTE$(1025)

8 FOR I=0 TO 7:BIT(I)=2^(7-I):NEXT I

15 FOR I=0 TO 127:Y=1+I*8:Z=2042-Y:K=I:FOR J=0 TO 7

16 IF K>=BIT(J) THEN K=K-BIT(J):BYTE$(Y+J,Y+J)=CHR$(160):BYTE$(Z+J,Z+J)=CHR$(32)

17 NEXT J:AL$(1+I,1+I)=CHR$(I):AL$(129+I)=CHR$(I+128):NEXT I

19 GOSUB 998

20 RESTORE:FOR I=1 TO 81:READ J:N$(I,I)=CHR$(J):NEXT I

27 DATA 0,104,104,169,1,141,1,3,169,82,141,2,3,169,0,141,4,3,169,0,141,5,3,169,0,141,10,3,169,0,141,11,3,32,83,228,96,0,0,0

28 DATA 104,160,0,162,4,104,149,202,202,208,250,177,205,145,203,152,145,205,163,203,24,105,40

29 DATA 144,2,230,204,133,203,232,230,205,224,96,240,250,224,128,208,227,96

30 ? "PLEASE INSERT THE DISK THAT":? "YOU WISH TO ACCESS":? :? :? "NOW ";

40 ? "ENTER THE SECTOR":? "NUMBER (1-1040) OF THE FIRST SECTOR":? "YOU WISH TO SCAN:";:POKE 764,255:INPUT SEC

45 IF SEC<1 OR SEC>1040 THEN 40

46 ? "IS IT A BOOT FILE (Y/N)?";:INPUT A$:LINK=125+3*(A$="Y")

50 POKE 752,1:?CHR$(125);:FL=23:SCRN$="":REM NULL STRING

60 CUSTOM=1:REM CONSECUTIVE(BOOT)=129

90 BUF2$=BUF$:SEC$=STR$(SEC):IF LEN(SEC$)<4 THEN SEC$(LEN(SEC$)+1)="    ":REM 4 SPACES

100 OFFSET=0:GOSUB 1000:N$(10,10)=CHR$(82):T=USR(ADR(N$)):IF PEEK(771)<>1 THEN 997

105 IF PTRIG(2)=0 THEN FOR I=1 TO PADDLE(2):NEXT I:GOTO 180

110 A$=BUF$(OFFSET+1):SCRN$(LEN(SCRN$)+1)=A$

120 VALUE=ASC(A$):VL$=STR$(VALUE):IF LEN(VL$)<3 THEN VL$(LEN(VL$)+1)="   ":REM 3 SPACES

130 OFF$=STR$(OFFSET):IF LEN(OFF$)<3 THEN OFF$(LEN(OFF$)+1)="   ":REM 3 SPACES

140 J=1+VALUE*8:IF FL<>23 THEN ?

145 B$=A$:IF ASC(B$)=155 THEN B$=CHR$(32)

146 BL$=AL$:IF ASC(BL$)=155 THEN BL$=CHR$(32)

150 ? " |";BYTE$(J,J+7);"|V=";VL$;"|C:  ";CHR$(27);B$;CHR$(27);BL$;"|S:";SEC$;"|O:";OFF$;

155 J=SCREEN+21+(23-FL)*40:POKE J,VALUE:POKE J+1,VALUE

156 J=PEEK(764):IF J=0 THEN 40

160 IF FL<>0 THEN FL=FL-1:OFFSET=OFFSET+1:GOTO 110

165 IF J<>255 THEN X=0:Y=23:SCR$=SCRN$:GOTO 200

170 POKE 764,255:SCRN$=SCRN$(2):OFFSET=OFFSET+1:IF OFFSET<LINK THEN 110

180 OLDSEC=SEC:IF LINK<>129 THEN 185

181 SEC=SEC+1:IF SEC>1040 THEN 50

182 GOTO 90

185 IF CUSTOM THEN 181

186 I=ASC(BUF$(126))/13:J=ASC(BUF$(127)):IF J=0 AND ((I<>INT(I)) OR I=0) THEN ? CHR$(253);:GOTO 181

190 SEC=J+256*INT(I):GOTO 90

200 POKE 764,255:LOC=SCREEN+4+X+40*Y:BIT=PEEK(LOC):S2=16:Z2=0

210 POKE LOC,BIT:POKE LOC,128-BIT:POKE 53279,8:Z=ASC(SCRN$(Y+1))

220 FUNC=PEEK(53279):IF FUNC<>7 THEN POKE LOC,BIT:POSITION 38,23:GOTO 300

221 IF PEEK(764)=255 THEN 230

222 CLOSE #2:OPEN #2,4,0,"K:":GET #2,I:CLOSE #2:IF I>64 AND I<71 THEN I=I-55:GOTO 228

223 IF I>47 AND I<58 THEN I=I-48:GOTO 228

224 IF I=19 THEN 400

227 GOTO 230

228 IF S2=16 THEN Z2=S2*I:S2=1:GOTO 230

229 S2=16:Z=Z2+I:Z2=0:POSITION 4,Y:? BYTE$(1+Z*8,8+Z*8);:BIT=128*(ASC(BYTE$(1+Z*8+X))<>32):GOTO 232

230 IF STRIG(0)<>0 THEN 240

231 BIT=128-BIT:POKE 53279,0:Z=Z+SGN(BIT/128-0.5)*BIT(X)

232 SCRN$(Y+1,Y+1)=CHR$(Z):POKE LOC-X+17,Z:POKE LOC-X-2,84:IF SCR$(Y+1,Y+1)=CHR$(Z) THEN POKE LOC-X-2,0

233 VL$=STR$(Z):IF LEN(VL$)<3 THEN VL$(LEN(VL$)+1)="   ":REM 3 SPACES

234 POSITION 15,Y:? VL$;:POSITION 23,Y

235 ? CHR$(27);CHR$(Z-123*(Z=155));CHR$(27);CHR$(ASC(AL$(Z+1))-123*(ASC(AL$(Z+1))=155));

240 S=STICK(0):IF S=15 THEN 210

250 POKE LOC,BIT:X=X+(S<8 AND X<7)-(S>8 AND S<12 AND X>0):SOUND 0,70,10,10

260 Y=Y+(S=5 OR S=9 OR S=13)-(S=6 OR S=10 OR S=14):IF Y>23 THEN Y=0

270 IF Y<0 THEN Y=23

280 SOUND 0,0,0,0:GOTO 200

300 IF FUNC<>3 THEN 170

301 IF STRIG(1)=0 THEN SCRN$=CHR$(0):SCRN$(24)=SCRN$:SCRN$(2)=SCRN$

305 IF SCRN$=SCR$ THEN 170

310 IF OFFSET>22 THEN BUF$(OFFSET-22,OFFSET+1)=SCRN$:GOTO 350

315 BUF$(1,OFFSET+1)=SCRN$(24-OFFSET,24):BUF2$((LINK)-(22-OFFSET),LINK)=SCRN$(1,23-OFFSET)

320 HB=INT(ADR(BUF2$)/256):LB=ADR(BUF2$)-HB*256:N$(15,15)=CHR$(LB):N$(20,20)=CHR$(HB)

330 HB=INT(OLDSEC/256):LB=OLDSEC-HB*256:N$(25,25)=CHR$(LB):N$(30,30)=CHR$(HB)

340 N$(10,10)=CHR$(87):T=USR(ADR(N$)):IF PEEK (771)<>1 THEN 997

350 GOSUB 1000:N$(10,10)=CHR$(87):T=USR(ADR(N$)):IF PEEK(771)<>1 THEN 997

390 GOTO 170

400 GRAPHICS 6:GOSUB 998:POKE 53248,0:POKE 705,56:I=SEC:J=PEEK(88)+256*PEEK(89)+1:K=0

410 GOSUB 1000:N$(10,10)=CHR$(82):T=USR(ADR(N$)):IF PEEK(771)<>1 THEN 997

415 ? "SECTOR :";SEC

416 FOR T=1 TO LINK:POKE J+K,ASC(BUF$(T)):K=K+20:IF K>1598 THEN K=K-1599:IF K=19 THEN K=0

419 NEXT T

420 REM POKE 53279,K*8+52:T=USR(ADR(N$)+40,ADR(BUF$),J+K)

430 SEC=SEC+1:IF SEC>1040 THEN SEC=1

440 IF PEEK(764)=255 THEN 410

450 POKE 764,255

460 IF STRIG(0)=0 THEN GRAPHICS 0:GOSUB 998:SEC=I:GOTO 50

470 IF PEEK(764)=255 THEN 460

480 POKE 764,255:GOTO 410

997 ? "ERROR!":STOP

998 POKE 54279,START:POKE 53277,2:POKE 704,12:POKE 705,56:POKE 709,15:POKE 710,0

999 POKE 53248,200:POKE 53249,48:POKE 559,42:RETURN

1000 HB=INT(ADR(BUF$)/256):LB=ADR(BUF$)-HB*256:N$(15,15)=CHR$(LB):N$(20,20)=CHR$(HB)

1010 HB=INT(SEC/256):LB=SEC-HB*256:N$(25,25)=CHR$(LB):N$(30,30)=CHR$(HB):RETURN

Link to comment
Share on other sites

Okay, this is a stupid question, but yesterday I typed in a program from my 600 XL manual into the Atari800Win+ Emulator, and tried to save it, but I couldn't. What do I need to do for this? (Mind you I've never owned an Atari 8-bit until this year)

Link to comment
Share on other sites

First you need a blank .atr to open as a disk drive for Atari800win - the .atr needs to be formatted and such so you have a proper diskette to save your program to.

 

I assume you have booted your ATari800win from a disk such that DOS is loaded? The .atr you booted from prob has enough space to save your Basic program also -

 

Once these things are in place you can type:

 

SAVE"D:MYGAME.BAS"

 

and wala its saved!

 

to load type:

LOAD"D:MYGAME.BAS"

 

If you are saving to another drive use:

 

SAVE"D2:MYGAME.BAS" (replace the 2 with whatever drive you want)

Link to comment
Share on other sites

If you forgot to "boot" a disk drive in the emulator, all is not lost. Simply save the state :)

 

If you wish to transfer the program from a saved state that has no Dos booted in memory, you can use the program NoDos to transfer the program to a blank .atr, boot Atari Dos, and then reload it using the NoDos routine. I believe that it should work fine on emulators...and it's short enough to type in quickly.

 

NoDos listing here:

http://www.atariage.com/forums/viewtopic.p...p=198912#198912

Link to comment
Share on other sites

Oops...I just checked out the requirements of the H: device.

NO "BOOTED" DOS IS REQUIRED TO USE THE PATCH! :) :)

 

To demonstrate this, uncheck the H: patch and clear all disk drives (alt-d->clear all). Restart the emulator with Basic and type this:

10 REM TEST

Now, without restarting...enable the patch in options and type:

SAVE"H:TEST.BAS"

No errors :)

By default, hard disk folders are set to the current directory where Atari800Win resides. You can change that by hitting alt-h and specifying folders you wish to use. By saving to a folder instead of a disk image, you also gain about 5k of Ram :D

Link to comment
Share on other sites

I agree with Zylon - My friends had an Apple II and C64 - they couldnt do anything outside of ML with those machines.  ATari basic is very friendly and exposed alot of fun stuff way back when :)

 

Amen to that! commodore basic V2 only has 3 redeeming commands- PEEK, POKE and SYS.

 

Not even a screen colour command - what the bejeezus were commodore thinking?

 

suppose it made the leap to assembler a lot easier seeing as the basic couldn't do much more than 6502 itself :)

Link to comment
Share on other sites

In alot of ways the Atari's friendliness prob turned out to be its worst enemy - Folks took the easy way programming it - Basic games (ug), 4 colors, etc.........  :(

 

As someone new to computers it was a dream though :)

 

I think Atari's worst enemy wasn't that BASIC was easy, it was that they didn't provide better access to documentation on the hardware to assembly programmers. Even once you bought the Assembler Editor cart and read the manual, you still didn't have the information you needed. It took Atari a while to decide to let developers see the hardware specs.

 

-Bry

Link to comment
Share on other sites

In alot of ways the Atari's friendliness prob turned out to be its worst enemy - Folks took the easy way programming it - Basic games (ug), 4 colors, etc.........  :(

 

As someone new to computers it was a dream though :)

 

I think Atari's worst enemy wasn't that BASIC was easy, it was that they didn't provide better access to documentation on the hardware to assembly programmers. Even once you bought the Assembler Editor cart and read the manual, you still didn't have the information you needed. It took Atari a while to decide to let developers see the hardware specs.

 

-Bry

 

Hence the release of the 8-Bit Bible: Mapping the Atari. I lived by it. :-)

Link to comment
Share on other sites

In alot of ways the Atari's friendliness prob turned out to be its worst enemy - Folks took the easy way programming it - Basic games (ug), 4 colors, etc.........  :(

 

i've always assumed that the friendliness of the BASIC is why i didn't do more with the Atari than piddle about a bit back in the day. i started on the VIC20 and was in the process of learning machine code when i got my 800XL, at which point i stopped dead and only resumed learning 65xx when i got the C64...

Link to comment
Share on other sites

I think Atari's worst enemy wasn't that BASIC was easy, it was that they didn't provide better access to documentation on the hardware to assembly programmers. Even once you bought the Assembler Editor cart and read the manual, you still didn't have the information you needed. It took Atari a while to decide to let developers see the hardware specs.

 

And this close architecture was one of the biggest problem for those companies int he eighties, while IBM developed an open architecture and with spec and everthing, of course It got a lot of "clones" (it made a different point of view doing business - some similar to open source).

 

devwebcl

Link to comment
Share on other sites

In alot of ways the Atari's friendliness prob turned out to be its worst enemy - Folks took the easy way programming it - Basic games (ug), 4 colors, etc.........  :(

 

i've always assumed that the friendliness of the BASIC is why i didn't do more with the Atari than piddle about a bit back in the day. i started on the VIC20 and was in the process of learning machine code when i got my 800XL, at which point i stopped dead and only resumed learning 65xx when i got the C64...

 

Man, I find it hard to believe that a good version of BASIC is a bad thing. BASIC was designed to make computers friendlier for the masses. I still say the main problem was a lack of good documentation once you left BASIC.

 

-Bry

Link to comment
Share on other sites

Man, I find it hard to believe that a good version of BASIC is a bad thing.

 

If a BASIC is good it abstracts itself away from the machine, it makes getting at certain facilities easy and anybody making the transition to machine code has to relearn what they already know.

 

BASIC was designed to make computers friendlier for the masses. I still say the main problem was a lack of good documentation once you left BASIC.

 

That essentially boils down to the same thing, Commodore BASIC gives the user a lot of the documentation, by the time a BASIC programmer moves over to machine code they already know where to write in memory for sprites, screen and border colour, screen and colour map RAM, the SID and so on.

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...