Changeset b9dcc8b in avrstuff
- Timestamp:
- Dec 2, 2012, 10:27:14 PM (11 years ago)
- Branches:
- main
- Children:
- 7d19206
- Parents:
- 9b0bfb3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CPC stuff/gordon/manager/gordon.z80
r9b0bfb3 rb9dcc8b 9 9 putc EQU 0xBB5A 10 10 screenmem EQU 0xBC08 11 fopen EQU 0xBC77 12 fread EQU 0xBC83 13 fclose EQU 0xBC7A 11 14 12 15 … … 23 26 ; This is the entry point when running as a standalone file 24 27 _start 28 ; Check the parameter count 29 CP 2 30 JP NZ,params_error 31 32 ; Load the file to burn 33 34 ; Get call parameter 35 LD L,(IX+2) 36 LD H,(IX+3) 37 ; Resolve BASIC string descriptor 38 LD B,(HL) ; length 39 INC HL 40 LD E,(HL) 41 INC HL 42 LD D,(HL) 43 EX DE,HL 44 45 LD DE,0x8000 46 CALL fopen 47 RET NC ; file not found (TODO print error message before leaving) 48 49 LD HL,0x2000 50 CALL fread 51 RET NC 52 53 CALL fclose 54 25 55 ; Ask the user to allow us to write to the flash memory 26 56 LD HL,MSG_WRITE_START … … 29 59 ; From there on, writing is enabled. This is ok as long as we don't 30 60 ; connect a writable ROM ! When we do, we have to make sure NOTHING 31 ; is read 61 ; is read/written from 8000-FFFF because the MegaFlash hardware 32 62 ; doesn't decode A14 and will answer for the whole 32k range. This 33 63 ; means, no use of firmware jumpblocks, and the stack needs to be … … 102 132 CALL screenmem 103 133 104 ; TODO clear screen 105 LD HL,0xC000 106 CALL DUMP 107 CALL 0xBB06 108 109 LD HL, 0xD000 110 CALL DUMP 111 CALL 0xBB06 112 113 LD HL, 0xE000 114 CALL DUMP 115 CALL 0xBB06 116 117 LD HL,0xF000 118 CALL DUMP 119 CALL 0xBB06 120 134 _exit 121 135 ; TODO cleanly get out (and handle both calls by RUN and CALL) 122 JR $ 136 RET 137 138 139 params_error 140 LD HL,MSG_HELP 141 CALL puts 142 JR _exit 123 143 124 144 … … 137 157 138 158 LD B,0xDF 139 LD C, 5 ; ROM number to write (FIXME get it as a RSX param)159 LD C,(IX+0) ; ROM number to write 140 160 OUT (C),C 141 161 … … 180 200 ; Ok, now that we erased the 4 sectors we needed, we can write data to them 181 201 LD HL, 0xC000 182 LD I X, 0x2000202 LD IY, 0x2000 183 203 PROGRAM 184 204 PUSH HL … … 190 210 191 211 LD B,0xDF 192 LD C, 5 ; ROM number to write (FIXME get it as a RSX param)193 OUT (C),C 194 195 LD A,(I X+ 0)212 LD C,(IX+0) ; ROM number to write 213 OUT (C),C 214 215 LD A,(IY + 0) 196 216 LD (HL),A ; Write occurs here. Need to wait 20 NOPs before next 197 217 ; operation on ROM. Our code is slow enough already ! 198 218 199 INC I X219 INC IY 200 220 INC HL 201 221 … … 216 236 CHECKBLANK 217 237 ; TODO select the right ROM 218 LD BC,0xDF05 238 LD B,0xDF 239 LD C,(IX+0) 219 240 OUT (C),C 220 241 … … 307 328 308 329 309 ; Dump some bytes from beginning of ROM 5310 DUMP311 DI312 313 ; Map the ROM in (stay in mode 1 and get system rom out)314 LD BC, 0x7F85315 OUT (C),C316 317 LD BC,0xDF05318 OUT (C),C319 320 ; Copy the ROM to RAM321 LD DE, 0x4000322 LD BC, 0x4000323 LDIR324 325 EI326 327 ; Dump the RAM (we're safe if the system maps another ROM this way)328 LD HL,0x4000329 plop330 LD A,(HL)331 INC HL332 CALL PRNHEX2333 DJNZ plop334 335 ; Wait for next command336 RET337 338 339 330 ; ----------------------------------------------------------------------------- 340 331 ; Messages … … 343 334 MSG_ERASE_ERR string "Erasing memory failed at address " 344 335 MSG_WRITE_OK string "Success!\r\n" 336 MSG_HELP string "CALL &1800,\"filename.rom\",nn\r\n" 345 337 346 338 ; ----------------------------------------------------------------------------- … … 376 368 377 369 370 ; Dump some bytes from beginning of ROM 5 371 DUMP 372 DI 373 374 ; Map the ROM in (stay in mode 1 and get system rom out) 375 LD BC, 0x7F85 376 OUT (C),C 377 378 LD BC,0xDF05 379 OUT (C),C 380 381 ; Copy the ROM to RAM 382 LD DE, 0x4000 383 LD BC, 0x4000 384 LDIR 385 386 EI 387 388 ; Dump the RAM (we're safe if the system maps another ROM this way) 389 LD HL,0x4000 390 plop 391 LD A,(HL) 392 INC HL 393 CALL PRNHEX2 394 DJNZ plop 395 396 ; Wait for next command 397 RET 398 399
Note:
See TracChangeset
for help on using the changeset viewer.