Now that I have a working print subroutine I wanted to incorporate it into the preferences program I created in the “6502, Branching Out” post. This new listing updates my PREFS program to print out some useful messages during runtime, and of course uses the new print subroutine.
Code
10 .OPT OBJ 20 *= $3600 39 ; Defines 40 NOISE = 65 50 RMARG = 82 51 CFORE = 709 52 CBACK = 710 53 KDELY = 729 54 KRATE = 730 55 CLICK = 731 60 OSNEW = $FFF7 61 OSOLD = $FFF8 70 CIOV = $E456 71 ICHID = $0340 ; IOCB 0 S: 72 ICCOM = $0342 ; IOCB Command 73 ICBAL = $0344 ; Xfer Buffer Adr 74 ICBAH = $0345 75 ICBLL = $0348 ; Buffer Len 76 ICBLH = $0349 80 EOL = $9B 82 CLS = $7D 98 ; 99 ; Identify Self 110 LDA #STITLE/256 112 LDY #STITLE&255 114 JSR PRINT 297 ; 298 ; Set universal OS stuff 299 ; 300 ; Print activity 302 LDA #SSETU/256 304 LDY #SSETU&255 306 JSR PRINT 310 ; Set left margin to 0 312 LDA #0 314 STA RMARG 320 ; Set background color 322 LDA #4 324 STA CBACK 330 ; Set text color 332 LDA #$0C 334 STA CFORE 340 ; Noisy I/O Off 342 LDA #0 344 STA NOISE 498 ; 499 ; Do XL/XE section? 500 ; XLXE OS R1,R2,R3,R4 502 LDA OSNEW 504 CMP #5 506 BCC XLXE 510 ; XLXE OS R10 512 LDA OSNEW 514 CMP #10 516 BEQ XLXE 520 ; XLXE OS R11 522 LDA OSNEW 524 CMP #11 526 BEQ XLXE 530 ; No Match 532 JMP DONE 999 ; 1000 XLXE 1010 ; Print XLXE Message 1012 LDA #SXLXE/256 1014 LDY #SXLXE&255 1016 JSR PRINT 1020 ; Set key repeat rate 1022 LDA #2 1024 STA KRATE 1030 ; Set key delay 1032 LDA #14 1034 STA KDELY 1040 ; No key click 1042 LDA #1 1044 STA CLICK 1898 ; 1899 ; Program Done 1900 DONE 1910 ; Print Done Message 1912 LDA #SDONE/256 1914 LDY #SDONE&255 1916 JSR PRINT 1920 ; Exit 1922 RTS 4999 ; 5000 ; Print Subroutine 5005 PRINT 5010 ; Store Starting String Address 5015 LDX #$00 5020 STA ICBAH,X 5030 TYA 5040 STA ICBAL,X 5050 ; Set IOCB Command 5055 LDA #$09 5060 STA ICCOM,X 5070 ; Set Max Buffer Length 5072 LDA #$FF 5080 STA ICBLH,X 5090 STA ICBLL,X 5100 ; Call CIO to Print 5105 JSR CIOV 5120 RTS 9999 ; 10000 ; String Data 10005 STITLE .BYTE CLS,"Atari 8 Preference Setter",EOL 10010 SSETU .BYTE "Setting universal preferences...",EOL 10020 SXLXE .BYTE "Setting XL/XE preferences...",EOL 10030 SDONE .BYTE "Done!",EOL
Breakdown
I’m not going to break down every line since they have all been covered at some point already. I will detail what sections of code are doing though.
Line 10 tells Mac/65 to produce object code.
Lines 20 tells the assembler where to place the code in memory.
Lines 40 to 82 setup various definitions for the assembler which make coding easier.
Lines 100 to 114 are used to display the title of the program which is the string pointed to by STITLE at line 10005 (“Atari 8 Preference Setter”).
Lines 300 to 344 are the universal settings sections. The settings here apply to all flavors of the Atari OS and are applied regardless of which machine the program is running on.
Lines 500 to 526 are the OS detection routine. If any of the checks succeed, control is passed to the XL/XE settings section of code which handles setting XL/XE specific settings.
Lines 530 to 532 pass control to the DONE section of code, which handles the program exit.
Lines 1000 to 1044 are the XL/XE settings section. It only gets executed if an XL or XE machine is detected.
Lines 1900 to 1922 are the last section of code to execute before the program stops. It prints the word “Done!” and exits.
Lines 5000 to 5120 are the screen print subroutine.
Lines 10000 to 10030 are the string data that gets printed to the screen.
Assembly
I saved it as “A8PREFS.M65”, and assembled it as “A8PREFS.COM”. I then set about testing it on 400/800 OS revision A, 400/800 OS revision B, Atari 800 XL OS, and Atari 130 XE OS. Since I’m using SpartaDOS with Mac/65 I had to copy A8PREFS.COM to another normal (90K) disk and boot the 400/800 machines with OSS DOS XL v2.2 since SpartaDOS v3.2g will not run on them.
Screen grab from it running on a 400/800 machine with OS revision A:
Screen grab from it running on a 400/800 machine with OS revision B:
Screen grab from it running on an 800 XL machine:
Screen grab from it running on an 130 XE machine:
Summary
It works exactly as I want – almost. Notice the output when running on an XL/XE machine. The word “Done” is printed at column 0 while the other text remains in column 2. Next I need to write a subroutine to position the cursor and spruce up the output a bit.