ATARI Macro Assembler Ver: 2.0A, RAMDISK.SRC ******* SmartRAM 2.5 ******* by Tim Patrick, the Happy Hacker ; ******* (c)1989 Antic Publishing, Inc. ; ******* RAMDISK DRIVE NUMBER = 0008 RAMDRV = 8 ;DOS 2.5=D8: ; ******* ZERO PAGE = 0014 RTCLOK = $14 = 0021 ICDNOZ = $21 = 0032 BUFRLO = $32 = 0033 BUFRHI = $33 = 0034 BFENLO = $34 = 0035 BFENHI = $35 ; ******* OTHER RAM = 03FA GINTLK = $3FA ;CARTRIDGE? = 03F8 BASICF = $3F8 ;ROM BASIC? = 02E0 RUNAD = $2E0 = 02E2 INITAD = $2E2 = 02EA DVSTAT = $2EA = 070A DRVBYT = $70A ;DRIVE MASK = 070C SASA = $70C ;END FMS CODE = 07E0 DINT = $7E0 ;FMS INIT = 4000 TSTLC = $4000 = 7400 VTOCP1 = $7400 ;RD1050 VTOC1 = 4000 VTOCP2 = $4000 ;RD1050 VTOC2 = 009B CR = $9B = 001C UP = $1C = 007D CLR = 125 = 00FD BELL = 253 = 001D DOWN = $1D = 001E LEFT = $1E = 001F RIGHT = $1F = 1481 GETBANK = $1481 ;DOS ROUTINES = 12CB SETBANK = $12CB = 07DF FASTRAM = $07DF ;SYNC W'VBI = 14C4 RAM_OUT = $14C4 ;RAMDISK EXIT = 0043 ZBUFP = $43 = 0042 CRITIC = $42 = 0B87 FIX_1 = $B87 = 105D S_FIX = $105D = 0780 DVLOC_1 = $780 ;BSIO = 0B89 DVLOC_2 = $B89 ;FORMAT = 105F DVLOC_3 = $105F ;STATUS = 0004 READ = 4 = 0008 WRITE = 8 = 0003 OPEN = 3 = 000C CLOSE = 12 = 0007 GET = 7 = 000B PUT = 11 = 153F MEMDUP = $153F ;MEM.SAV/DUP = 008B NAK_ERR = 139 = 183A M_ADDR = $183A = 1863 T_ADDR = M_ADDR+MEMEND-MEMFIX ; ******* OS ROM VECTORS = E453 DSKINV = $E453 = E456 CIOV = $E456 = E459 SIOV = $E459 ; ******* CHIP REGISTERS = D301 PORTB = $D301 = D40E NMIEN = $D40E ; ******* DCB/IOCB = 0300 DDEVIC = $300 = 0301 DUNIT = $301 = 0302 DCOMND = $302 = 0303 DSTATS = $303 = 0304 DBUFLO = $304 = 0305 DBUFHI = $305 = 030A DAUX1 = $30A = 030B DAUX2 = $30B ; = 0342 ICCOM = $342 = 0344 ICBAL = $344 = 0345 ICBAH = $345 = 0348 ICBLL = $348 = 0349 ICBLH = $349 = 034A ICAX1 = $34A = 034B ICAX2 = $34B ; ******* MACROS SKW MACRO ;SKIP WORD DB $FC ;BRANCH +2 ENDM SKB MACRO ;SKIP BYTE DB $F4 ;BRANCH +1 ENDM ; ******* INSTALLATION ROUTINE ; 0000 = 3000 ORG $3000 ; ******* 256K EXTENDED MEMORY TEST ; 3000 AD01D3 INSTAL LDA PORTB 3003 09FC ORA #$FC ;SET ALL BITS 3005 48 PHA ;(SAVE IT) 3006 AA TAX ;NORMAL IN X 3007 ACAD33 LDY BIT_X ;XE BANK IN Y 300A 20EC32 JSR MEMTST ;TEST IT 300D 1002 ^3011 BPL TEST6 ; 300F 68 PLA ;NO EXTRA RAM 3010 60 RTS ;BYE! ; 3011 AE9C33 TEST6 LDX BIT_6 ;ANY AT 6? 3014 20EC32 JSR MEMTST 3017 8DB133 STA EXTRA ;192K FLAG(0) ; 301A AEA033 TEST5 LDX BIT_5 ;HOW ABOUT 5? 301D 20EC32 JSR MEMTST 3020 3012 ^3034 BMI TEST7 ; ******* NEWELL/RAMBO? ; 3022 EEB133 INC EXTRA ;BIT-6(+)? 3025 D023 ^304A BNE MEMX ;YUP, RAMBOXL ; 3027 A203 LDX #3 3029 BDA933 LPN LDA NEWELL,X ;FIX TABLE 302C 9D9C33 STA TABLE,X ;FOR NEWELL 302F CA DEX 3030 10F7 ^3029 BPL LPN 3032 3013 ^3047 BMI EXIT ; ******* TEST FOR BIT-7 ; 3034 AEA533 TEST_7 LDX BIT_7 3037 20EC32 JSR MEMTST 303A 300E ^304A BMI MEMX ; 303C A203 LDX #3 303E BDA533 LP7 LDA BIT_7,X ;FIX TABLE 3041 9DA033 STA TABLE2,X ;FOR BIT-7 3044 CA DEX 3045 10F7 ^303E BPL LP7 ; ******* RAM TEST EXIT ; 3047 EEB133 EXIT INC EXTRA ;256K FLAG(+) ; 304A 68 MEMX PLA ;FIX $D301 304B 8D01D3 STA PORTB 304E ADB133 LDA EXTRA ;(-) = 128K 3051 F024 ^3077 BEQ FIX_192 ;(0) = 192K 3053 1025 ^307A BPL FIX_DOS ;(+) = 256K ; ******* 130XE RAMDISK INITIALIZATION ; 3055 A0CA XE_TYPE LDY #$CA ;(DEX) 3057 8CDA30 STY V_TST1 305A EEE230 INC V_TST2+1 ; 305D A003 LDY #3 305F 8CED30 STY CLEAR+1 ;ONLY 4 BANKS 3062 B9AD33 XE_FIX LDA BIT_X,Y ;FIX TABLE 3065 999C33 STA TABLE,Y ;AND MESSAGE 3068 B97330 LDA XE_MSG,Y ;FOR 130XE 306B 993333 STA MSG1+24+2,Y 306E 88 DEY 306F 10F1 ^3062 BPL XE_FIX 3071 300A ^307D BMI MERGE ; 3073 4449534B XE_MSG DB 'DISK' ; ******* PATCH DOS 2.5 FOR 192/256K ; 3077 20D632 FIX_192 JSR SIXFIX ;ONLY 192K ; 307A 203A32 FIX_DOS JSR DOSFIX ;PATCH DOS ; ******* MERGE RAMDISK WITH DOS ; 307D A908 MERGE LDA #RAMDRV ;INSTALL 307F AA TAX 3080 8D8007 STA DVLOC_1 ;DRIVE 3083 8D890B STA DVLOC_2 ;NUMBER 3086 8D5F10 STA DVLOC_3 ;(DECIMAL) 3089 18 CLC 308A 6930 ADC #'0' ;(ASCII) 308C 8D9933 STA DRIVE+1 308F 8D3133 STA MSG1+24 3092 8D7031 STA DRIVE_1+1 3095 8DD631 STA DRIVE_2+1 ; 3098 A900 LDA #0 309A 38 SEC ;SET 1 BIT, 309B 2A DRVLP ROL A ;THEN SHIFT 309C CA DEX ;TO POSITION 309D D0FC ^309B BNE DRVLP 309F 0D0A07 ORA DRVBYT 30A2 8D0A07 STA DRVBYT ;ADD TO TABLE 30A5 20E007 JSR DINT ; ******* PRINT SMARTRAM MESSAGE ; 30A8 A219 LDX #LOW MSG1 30AA A033 LDY #HIGH MSG1 30AC A94F LDA #[MSGEND-MSG1] 30AE 8D4803 STA ICBLL 30B1 8E4403 STX ICBAL 30B4 8C4503 STY ICBAH 30B7 A200 LDX #0 30B9 8E4903 STX ICBLH 30BC A90B LDA #PUT 30BE 8D4203 STA ICCOM 30C1 2056E4 JSR CIOV ; ******* CHECK IF PREVIOUSLY FORMATTED ; 30C4 A202 LDX #2 30C6 AD01D3 LDA PORTB 30C9 48 PHA 30CA 09FC ORA #$FC 30CC 3D9C33 AND TABLE,X ;SELECT VTOC 30CF 8D01D3 STA PORTB ;RAMDISK BANK ; 30D2 A000 LDY #0 ;COMPARE 30D4 EC0074 V_TST0 CPX VTOCP1 ;VTOC BYTE-1 30D7 F001 ^30DA BEQ V_TST1 30D9 C8 INY 30DA E8 V_TST1 INX 30DB EC0274 CPX VTOCP1+2 ;VTOC BYTE-3 30DE F001 ^30E1 BEQ V_TST2 30E0 C8 INY 30E1 A2F2 V_TST2 LDX #$F2 30E3 EC0174 CPX VTOCP1+1 ;VTOC BYTE-2 30E6 F001 ^30E9 BEQ V_DONE 30E8 C8 INY 30E9 98 V_DONE TYA ;FORMATTED? 30EA F042 ^312E BEQ NO_FMT ; ******* CLEAR EXTRA RAM ; 30EC A207 CLEAR LDX #7 ;BANKS 0->7 30EE AD01D3 FLP1 LDA PORTB 30F1 09FC ORA #$FC 30F3 3D9C33 AND TABLE,X ;GET FIRST 30F6 8D01D3 STA PORTB 30F9 A240 LDX #$40 ;SET UP 30FB 8633 STX BUFRHI ;INDIRECT 30FD A000 LDY #0 ;ADDRESS 30FF 8432 STY BUFRLO 3101 98 TYA ;CLEAR "A" 3102 9132 FLP2 STA (BUFRLO),Y ;CLEAR A PAGE 3104 C8 INY 3105 D0FB ^3102 BNE FLP2 3107 E633 INC BUFRHI ;NEXT PAGE 3109 CA DEX 310A D0F6 ^3102 BNE FLP2 310C CEED30 DEC CLEAR+1 ;NEXT BANK 310F 10DB ^30EC BPL CLEAR ; ******* SET UP XIO TO FORMAT ; 3111 203032 XIOFMT JSR DO_CLOSE ;CHANNEL-4 3114 A9FE LDA #254 ;XIO FORMAT 3116 9D4203 STA ICCOM,X 3119 A998 LDA #LOW DRIVE 311B 9D4403 STA ICBAL,X 311E A933 LDA #HIGH DRIVE 3120 9D4503 STA ICBAH,X 3123 A900 LDA #0 3125 9D4B03 STA ICAX2,X 3128 9D4A03 STA ICAX1,X 312B 2056E4 JSR CIOV ; 312E 68 NO_FMT PLA 312F 8D01D3 STA PORTB ; ******* MOVE DUP.SYS TO D8: ; 3132 203032 JSR DO_CLOSE ;CLOSE FIRST 3135 A903 LDA #OPEN ;OPEN 3137 9D4203 STA ICCOM,X 313A A904 LDA #READ ;FOR READ 313C 9D4A03 STA ICAX1,X 313F A982 LDA #LOW FILE ;D1:DUP.SYS 3141 9D4403 STA ICBAL,X 3144 A933 LDA #HIGH FILE 3146 9D4503 STA ICBAH,X 3149 2056E4 JSR CIOV 314C 301C ^316A BMI OOPS_1 ;NO DUP(?) ; ******* READ IT IN TO BUFFER ; 314E A907 LDA #GET ;COPY FILE 3150 9D4203 STA ICCOM,X 3153 A906 LDA #LOW SIZE 3155 9D4803 STA ICBLL,X 3158 A914 LDA #HIGH SIZE 315A 9D4903 STA ICBLH,X 315D A9B3 LDA #LOW BUFFER 315F 9D4403 STA ICBAL,X ;TO BUFFER 3162 A933 LDA #HIGH BUFFER 3164 9D4503 STA ICBAH,X 3167 2056E4 JSR CIOV 316A 3022 ^318E OOPS_1 BMI OOPS_2 316C 203032 JSR DO_CLOSE ; ******* SWITCH TO D8: (#RAMDRV) ; 316F A938 DRIVE_1 LDA #8+'0' ;SET RAMDRIVE 3171 8D8333 STA FILE+1 3174 8D8E33 STA MEM_SAV+1 ; ******* NOW OPEN FOR WRITE ; 3177 A903 OPEN_8 LDA #OPEN ;OPEN 3179 9D4203 STA ICCOM,X 317C A908 LDA #WRITE ;FOR WRITE 317E 9D4A03 STA ICAX1,X 3181 A982 LDA #LOW FILE ;D8:DUP.SYS 3183 9D4403 STA ICBAL,X 3186 A933 LDA #HIGH FILE 3188 9D4503 STA ICBAH,X 318B 2056E4 JSR CIOV 318E 301C ^31AC OOPS_2 BMI OOPS_3 ; ******* WRITE DUP.SYS TO D8: ; 3190 A90B WRTDUP LDA #PUT ;PUT BYTES 3192 9D4203 STA ICCOM,X 3195 A906 LDA #LOW SIZE 3197 9D4803 STA ICBLL,X 319A A914 LDA #HIGH SIZE 319C 9D4903 STA ICBLH,X 319F A9B3 LDA #LOW BUFFER ;FROM BUFFER 31A1 9D4403 STA ICBAL,X 31A4 A933 LDA #HIGH BUFFER 31A6 9D4503 STA ICBAH,X 31A9 2056E4 JSR CIOV ;WRITE FILE 31AC 3064 ^3212 OOPS_3 BMI OOPS_4 ;(NEVER!) ; ******* CREATE MEM.SAV FILE ; 31AE 203032 JSR DO_CLOSE 31B1 ADFA03 LDA GINTLK 31B4 D005 ^31BB BNE MEM_FIL 31B6 ADF803 LDA BASICF 31B9 D017 ^31D2 BNE DUP_MEM 31BB A903 MEM_FIL LDA #OPEN ;OPEN 31BD 9D4203 STA ICCOM,X 31C0 A908 LDA #WRITE ;FOR WRITE 31C2 9D4A03 STA ICAX1,X 31C5 A98D LDA #LOW MEMSAV ;D8:MEM.SAV 31C7 9D4403 STA ICBAL,X 31CA A933 LDA #HIGH MEMSAV 31CC 9D4503 STA ICBAH,X 31CF 2056E4 JSR CIOV ; ******* USE D8:DUP.SYS/MEM.SAV ; 31D2 203032 DUP_MEM JSR DO_CLOSE 31D5 A938 DRIVE_2 LDA #8+'0' 31D7 8D3F15 STA MEMDUP ; ******* IF 130XE, EXIT HERE ; 31DA ADB133 LDA EXTRA 31DD 3051 ^3230 BMI DO_CLOSE ; ******* UPDATE DUP.SYS MENU ; 31DF A903 LDA #OPEN ;OPEN 31E1 9D4203 STA ICCOM,X 31E4 A90C LDA #READ+WRITE ;FOR UPDATE 31E6 9D4A03 STA ICAX1,X 31E9 A982 LDA #LOW FILE ;D8:DUP.SYS 31EB 9D4403 STA ICBAL,X 31EE A933 LDA #HIGH FILE 31F0 9D4503 STA ICBAH,X 31F3 2056E4 JSR CIOV ; ******* POINT TO DUP MENU TITLE ; 31F6 A907 LDA #GET ;GET 31F8 9D4203 STA ICCOM,X 31FB A930 LDA #LOW 48 ;48 BYTES 31FD 9D4803 STA ICBLL,X 3200 A900 LDA #HIGH 48 3202 9D4903 STA ICBLH,X 3205 A9B3 LDA #LOW BUFFER 3207 9D4403 STA ICBAL,X 320A A933 LDA #HIGH BUFFER 320C 9D4503 STA ICBAH,X 320F 2056E4 JSR CIOV 3212 301C ^3230 OOPS_4 BMI DO_CLOSE ;(HUH?) ; ******* WRITE THE NEW TEXT DATA ; 3214 A90B LDA #PUT ;NOW, PUT 3216 9D4203 STA ICCOM,X 3219 A91A LDA #LOW [FILE-DUPMOD] 321B 9D4803 STA ICBLL,X 321E A900 LDA #HIGH [FILE-DUPMOD] 3220 9D4903 STA ICBLH,X 3223 A968 LDA #LOW DUPMOD ;NEW TEXT 3225 9D4403 STA ICBAL,X 3228 A933 LDA #HIGH DUPMOD 322A 9D4503 STA ICBAH,X 322D 2056E4 JSR CIOV ;INTO MENU ; ******* BE NEAT, CLOSE IT UP. ; 3230 A240 DOCLOSE LDX #$40 3232 A90C LDA #CLOSE 3234 9D4203 STA ICCOM,X 3237 4C56E4 JMP CIOV ;BYE, BYE ; ********************* ******* * ******* SUBROUTINES * ******* * ********************* ; ******* PATCH DOS 2.5 FOR 256K ; 323A A909 DOS_FIX LDA #9 323C 8D8E14 STA $148E 323F A941 LDA #$41 3241 8D9514 STA $1495 ; 3244 A00A LDY #SETEND-SETFIX-1 3246 B98E32 ST_FIX LDA SETFIX,Y 3249 99DE12 STA $12DE,Y 324C 88 DEY 324D 10F7 ^3246 BPL ST_FIX ; 324F A013 LDY #RAMEND-RAMFIX-1 3251 B99932 RM_FIX LDA RAMFIX,Y 3254 99C414 STA RAMOUT,Y 3257 88 DEY 3258 10F7 ^3251 BPL RM_FIX ; 325A A008 LDY #8 325C B99C33 T_MOVE LDA TABLE,Y 325F 996318 STA T_ADDR,Y 3262 88 DEY 3263 10F7 ^325C BPL T_MOVE 3265 A963 LDA #LOW T_ADDR 3267 8DE712 STA T_FIX+1 326A A918 LDA #HIGH T_ADDR 326C 8DE812 STA T_FIX+2 ; 326F ADC317 LDA $17C3 3272 18 CLC 3273 6902 ADC #MF_2-MEMFIX 3275 8DCA17 STA $17CA 3278 A028 LDY #MEMEND-MEMFIX-1 327A B9AD32 M_MOVE LDA MEMFIX,Y 327D 993A18 STA M_ADDR,Y 3280 88 DEY 3281 10F7 ^327A BPL M_MOVE ; ******* DRIVE FORMAT TABLE FIX ; 3283 A98A LDA #$8A 3285 8D5D10 STA S_FIX 3288 A906 LDA #6 ;OFFSET-6 328A 8D870B STA FIX_1 328D 60 RTS ; ********************* ******* * ******* THE FIXES * ******* * ********************* ; ******* SET-BANK ROUTINE ; 328E = 12DE# SETFIX LOC $12DE 12DE# 2907 AND #%00000111 ;1024 = 0 12E0# A8 FINISH TAY 12E1# AD01D3 LDA PORTB 12E4# 09FC ORA #$FC ;SET ALL 12E6# 399C33 T_FIX AND TABLE,Y ;SELECT BANK ; 12E9# = 3299 ORG *O = 3299 SETEND = * ; ******* RAMDISK I/O EXIT ; 3299 = 14C4# RAMFIX LOC RAM_OUT ;($14C4) 14C4# AD01D3 LDA PORT_B 14C7# 09FC ORA #$FC ;SET NO BANK 14C9# 8D01D3 STA PORT_B 14CC# A0C0 LDY #$C0 14CE# 8C0ED4 STY NMIEN ;RESTORE NMI 14D1# A000 LDY #0 14D3# 8442 STY CRITIC ;CLEAR CRITIC 14D5# 58 CLI ;RESTORE IRQ 14D6# C8 INY ;GOOD STATUS 14D7# 60 NEW_OUT RTS ;(+3 BYTES) ; 14D8# = 32AD ORG *O = 32AD RAMEND = * ; 32AD FD9B MEMFIX DB BELL,CR 32AF 1C4552524F MF_2 DB UP,'ERROR WRITING MEM.SAV - Y TO RUN DOS!',CR = 32D6 MEMEND = * ; ******* 192K RAMDISK INITIALIZATION ; 32D6 A003 SIX_FIX LDY #3 32D8 B9AD33 FIX_6 LDA BIT_X,Y ;FIX TABLE 32DB 99A033 STA TABLE2,Y ;AND MESSAGE 32DE B9E832 LDA MSG_192,Y ;FOR 192K 32E1 997533 STA DUPMOD+13,Y 32E4 88 DEY 32E5 10F1 ^32D8 BPL FIX_6 32E7 60 RTS ; 32E8 B1B9B2CB MSG_192 DC '1','9','2','K' ; ******* MEMORY TEST ; 32EC 8C01D3 MEMTST STY PORTB 32EF AD0040 LDA TSTLC ;GET BYTE 32F2 48 PHA ;AND SAVE IT 32F3 8E01D3 STX PORTB ;SWAP BANKS 32F6 CD0040 CMP TSTLC ;THEN COMPARE 32F9 D013 ^330E BNE YUP 32FB 8C01D3 STY PORTB ;INCASE DATA 32FE 49FF EOR #$FF ;IS SAME 3300 8D0040 STA TSTLC ;INVERT IT 3303 8E01D3 STX PORTB ;AND COMPARE 3306 CD0040 CMP TSTLC ;AGAIN... 3309 D003 ^330E BNE YUP 330B A2FF NOPE LDX #$FF ;FAILED FLAG 330D SKW ;(SKIP WORD) 330D +FC DB $FC ;(BRANCH +2) 330E A200 YUP LDX #0 ;PASSED FLAG 3310 8C01D3 STY PORTB 3313 68 PLA ;RESTORE BYTE 3314 8D0040 STA TSTLC 3317 8A TXA ;SET FLAG 3318 60 RTS ; ******* SMARTRAM MESSAGE ; ;SmartRAM-II DOS 2.5 D8:1050 EMULATOR ;by Tim Patrick, COPYRIGHT 1989 ANTIC ; 3319 7D1C1C MSG1 DB CLR,UP,UP 331C 536D617274 DB 'SmartRAM-II DOS 2.5 D8:1050 EMULATOR' 3340 9B DB CR 3341 6279205469 DB 'by Tim Patrick, COPYRIGHT 1989 ANTIC' 3365 1F1F1D DB RIGHT,RIGHT,DOWN = 3368 MSGEND = * ; ******* FILENAMES AND DATA ; 3368 CDCFC4C9C6 DUPMOD DC 'M','O','D','I','F','I' 336E C5C4A0C6CF DC 'E','D',' ','F','O','R' 3374 A0B2B5B6CB DC ' ','2','5','6','K',' ' 337A CDC1C3C8C9 DC 'M','A','C','H','I','N' 3380 C5A1 DC 'E','!' 3382 44313A4455 FILE DB 'D1:DUP.SYS',CR 338D 44383A4D45 MEM_SAV DB 'D8:MEM.SAV',CR = 1406 SIZE = 5126 3398 44383A9B DRIVE DB 'D8:',$9B ; ******* MASTER BANK CONTROL TABLE ; 339C A3A7ABAF TABLE DB $A3,$A7,$AB,$AF 33A0 C3C7CBCF TABLE2 DB $C3,$C7,$CB,$CF 33A4 FF NORMAL DB $FF = 339C BIT_6 = TABLE = 33A0 BIT_5 = TABLE2 ; ******* EXTRA RAM CONTROL BYTES ; 33A5 63676B6F BIT_7 DB $63,$67,$6B,$6F 33A9 83878B8F NEWELL DB $83,$87,$8B,$8F 33AD E3E7EBEF BIT_X DB $E3,$E7,$EB,$EF 33B1 00 EXTRA DB 0 ; ******* DUP.SYS COPY BUFFER ; = 33B3 BUFFER = *+1 33B2 END INSTAL no ERRORs, 139 Labels, $43F2 free. Tim Patrick * Kailua, HI 96734
Back to previous page