Changeset 0853bac in avrstuff
- Timestamp:
- Dec 1, 2012, 2:24:57 PM (11 years ago)
- Branches:
- main
- Children:
- 9b0bfb3
- Parents:
- 7c25c3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CPC stuff/gordon/manager/gordon.z80
r7c25c3e r0853bac 42 42 ; Save the interrupt vector and replace it with EI/RET 43 43 LD HL,(0x38) 44 44 LD (inthandle),HL 45 45 LD HL,0xC9FB 46 46 LD (0x38),HL 47 47 48 ; Now that we got the system out of the way, map the ROM 49 ; (we stay in mode 1) 50 LD BC, 0x7F85 51 OUT (C),C 52 48 53 ; TODO get the ROM number to burn somehow ? 49 54 ; (we can get it as a CALL parameter) 50 55 51 56 CALL ERASE 52 CALL WRITE 57 CALL CHECKBLANK 58 59 ; Load the "erase error" message. If erase actually succeded, we will go 60 ; to the write function which will set something else. 61 ; DE holds the error address 62 EX DE,HL 63 LD HL,MSG_ERASE_ERR 64 LD (status),HL 65 CALL Z,WRITE 53 66 54 67 ; Disconnect the Megaflash … … 58 71 ; Restore the firmware in working order now that we are done 59 72 LD SP,(stack) 60 61 73 LD HL,(inthandle) 74 LD (0x38),HL 62 75 EI 63 76 … … 67 80 CALL screenmem 68 81 82 ; TODO clear screen 83 84 ; Print the error/success message 85 LD HL,(status) 86 CALL puts 87 88 ; Print DE so we know where the problem was 89 LD A,D 90 CALL PRNHEX2 91 LD A,E 92 CALL PRNHEX2 93 94 ; Now user can safely disconnect the ROM 69 95 LD HL,MSG_WRITE_END 70 96 CALL puts … … 76 102 CALL screenmem 77 103 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 78 121 ; TODO cleanly get out (and handle both calls by RUN and CALL) 79 122 JR $ 123 80 124 81 125 ; Erase a 16K ROM. Input: … … 83 127 ; Assumes we are in write mode, interrupts disabled. 84 128 ERASE 85 129 LD B,4 86 130 eraseloop 87 131 PUSH BC 88 132 89 133 LD A, 0x80 ; ERASE … … 98 142 ; Compute address near start of sector 99 143 POP BC 100 LD A,B 101 DEC A102 SLA A103 SLA A104 105 ADD 0xC0144 145 LD HL, addrmap-1 146 LD D,0 147 LD E,B 148 ADD HL,DE 149 LD A,(HL) 106 150 107 151 LD H,A … … 119 163 HALT 120 164 HALT 121 165 HALT 122 166 HALT 123 167 DI … … 127 171 RET 128 172 173 addrmap defb 0xC0, 0xD0, 0xE0, 0xF0 129 174 130 175 ; Write a 16K ROM … … 137 182 LD IX, 0x2000 138 183 PROGRAM 139 184 PUSH HL 140 185 141 186 LD A, 0xA0 ; BYTE PROGRAM … … 161 206 JR NZ, PROGRAM 162 207 163 RET 164 208 LD HL,MSG_WRITE_OK 209 LD (status),HL 210 RET 211 212 213 ; Check if the ROM was erased properly and contains all FF bytes. 214 ; Input: upper ROM is connected 215 ; Output: Z flag set if all ok, else HL points to error 216 CHECKBLANK 217 ; TODO select the right ROM 218 LD BC,0xDF05 219 OUT (C),C 220 221 LD HL, 0xC000 222 .checkbyte 223 LD A,(HL) 224 225 CP 0xFF 226 RET NZ 227 228 INC HL 229 LD A,H 230 OR A 231 RET Z 232 JR .checkbyte 165 233 ; Helper routines ----------------------------------------------------- 166 234 … … 218 286 RET 219 287 220 ; ----------------------------------------------------------------------------- 221 ; Messages 222 MSG_WRITE_START string "Turn write switch ON and press a key...\r\n" 223 MSG_WRITE_END string "Turn write switch OFF and press a key...\r\n" 224 225 ; ----------------------------------------------------------------------------- 226 SECTION .uninit,"urw" 227 228 stack DEFW 1 229 inthandle DEFW 1 230 231 end 232 233 ; Very basic command prompt/monitor stuff for testing 234 ; Print prompt 235 LD A,'?' 236 CALL 0xBB5A 237 ; Wait for key 238 CALL 0xBB06 239 ; Parse commands 240 CP A,'d' 241 JP Z,DUMP 242 CP A,'e' 243 JP Z,ERASE 244 CP A,'w' 245 JP Z,WRITE 246 247 ; Unhandled command 248 LD A,'X' 249 CALL 0xBB5A 250 251 ; Start over 252 JR _start 253 254 255 ; Dump some bytes from beginning of ROM 5 256 DUMP 257 DI 258 259 ; Map the ROM in (stay in mode 1 and get system rom out) 260 LD BC, 0x7F85 261 OUT (C),C 262 263 LD BC,0xDF05 264 OUT (C),C 265 266 ; Copy the ROM to RAM 267 LD DE, 0x4000 268 LD BC, 0x4000 269 LD HL, 0xC000 270 LDIR 271 272 EI 273 274 ; Dump the RAM (we're safe if the system maps another ROM this way) 275 LD HL,0x4000 276 plop 277 LD A,(HL) 278 INC HL 279 CALL PRNHEX2 280 DJNZ plop 281 282 ; Wait for next command 283 JP _start 284 285 286 PRNHEX2 ;affiche la valeur de A sur 2 chiffres 287 ; en hexad{cimal 288 ; Print A value as hexadecimal 289 ; AF is corrupt 290 PRNHEX2 288 291 PUSH AF 289 292 RRA … … 304 307 305 308 306 PRNHEX2 ;affiche la valeur de A sur 2 chiffres 307 ; en hexad{cimal 308 PUSH AF 309 RRA 310 RRA 311 RRA 312 RRA ;divise A par 8 313 CALL PRNHEX1 ;affiche le premier morceau 314 POP AF ;r{cup la valeur originale pour la suit 315 PRNHEX1 ;affiche la valeur de A sur 1 chiffre 316 ;affiche A sur 1 chiffre en Hexa 317 AND 0xF ;ne prend que les unit{s 318 OR A 319 DAA ;convertit en d{cimal 320 ADD A,0xF0 ;ajoute 240 321 ADC A,0x40 ;ajoute 64+le carry (si >15) 322 ;on a le code ascii du chiffre @ afficher 323 JP 0xBB5A ;call-ret 324 325 309 ; Dump some bytes from beginning of ROM 5 310 DUMP 311 DI 312 313 ; Map the ROM in (stay in mode 1 and get system rom out) 314 LD BC, 0x7F85 315 OUT (C),C 316 317 LD BC,0xDF05 318 OUT (C),C 319 320 ; Copy the ROM to RAM 321 LD DE, 0x4000 322 LD BC, 0x4000 323 LDIR 324 325 EI 326 327 ; Dump the RAM (we're safe if the system maps another ROM this way) 328 LD HL,0x4000 329 plop 330 LD A,(HL) 331 INC HL 332 CALL PRNHEX2 333 DJNZ plop 334 335 ; Wait for next command 336 RET 337 338 339 ; ----------------------------------------------------------------------------- 340 ; Messages 341 MSG_WRITE_START string "Turn write switch ON and press a key...\r\n" 342 MSG_WRITE_END string "Turn write switch OFF and press a key...\r\n" 343 MSG_ERASE_ERR string "Erasing memory failed at address " 344 MSG_WRITE_OK string "Success!\r\n" 345 346 ; ----------------------------------------------------------------------------- 347 SECTION .uninit,"urw" 348 349 stack DEFW 1 350 inthandle DEFW 1 351 status DEFW 1 352 353 end 354 ; END END END END END END END END END END END END END END END END END END END 355 356 ; Very basic command prompt/monitor stuff for testing 357 ; Print prompt 358 LD A,'?' 359 CALL 0xBB5A 360 ; Wait for key 361 CALL 0xBB06 362 ; Parse commands 363 CP A,'d' 364 JP Z,DUMP 365 CP A,'e' 366 JP Z,ERASE 367 CP A,'w' 368 JP Z,WRITE 369 370 ; Unhandled command 371 LD A,'X' 372 CALL 0xBB5A 373 374 ; Start over 375 JR _start 376 377
Note:
See TracChangeset
for help on using the changeset viewer.