Changeset 67031cd in avrstuff
- Timestamp:
- Nov 18, 2012, 10:09:19 PM (11 years ago)
- Branches:
- main
- Children:
- 413443e
- Parents:
- 7dcccbc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CPC stuff/gordon/manager/gordon.z80
r7dcccbc r67031cd 10 10 ; get a bit messy so maybe we will need to use the screen at 4000 as a buffer 11 11 ; for the ROM data as well. Or just use a bank for that ? 12 ; TODO 12 13 13 14 ; Map the ROM in 14 ; TODO 15 LD BC, 0x7F85 16 OUT (C),C 15 17 16 18 ; ask the user to enable writing 17 ; TODO19 ; TODO 18 20 19 ; Check if we can read the ROM type 20 LD A, 0x90 21 ; Turns out with the MegaFlash design, we can't both read and write. When the 22 ; memory is in write mode, reading is disabled. This means we can't identify 23 ; the chip, or use the data polling features. And we have to go for the 24 ; worst-case timing given in the datasheet :( 25 26 ; ... anyway, start with erasing the sectors we need. 27 CALL 0xBD19 28 LD B, 4 29 ERASE 30 PUSH BC 31 32 LD A, 0x80 ; ERASE 21 33 CALL send_command 22 34 35 CALL prepare_command 36 37 LD B,0xDF 38 LD C,5 ; ROM number to write (FIXME get it as a RSX param) 39 OUT (C),C 40 41 ; Compute address near start of sector 42 POP BC 43 LD A,B 44 DEC A 45 SLA A 46 SLA A 47 48 ADD 0xC0 49 50 LD H,A 51 52 LD E, 0x30 53 LD (HL), E 54 55 ; This will delay long enough - we need at least 25ms 56 CALL 0xBD19 57 58 DJNZ ERASE 59 60 ; Ok, now that we erased the 4 sectors we needed, we can write data to them 23 61 LD HL, 0xC000 62 LD IX, 0x4000 63 PROGRAM 64 LD A, 0xA0 ; BYTE PROGRAM ; 2 10 65 PUSH HL ; 3 13 66 CALL send_command ; 5 18 24 67 25 LD A,(HL) 26 CALL printhex 27 INC L 28 LD A,(HL) 29 CALL printhex 68 LD B,0xDF 69 LD C,5 ; ROM number to write (FIXME get it as a RSX param) 70 OUT (C),C 30 71 31 ; We should get 0x8F 87 32 ; TODO check that before continuing with writing the data 72 POP HL 73 74 LD A,(IX + 0) 75 LD (HL),A ; Write occurs here. Need to wait 20 NOPs before next 76 ; operation on ROM. Our code is slow enough already ! 77 78 INC HL ; 2 2 79 INC IX ; 3 5 80 JR NC, PROGRAM ; 3 8 81 33 82 JR $ 34 83 35 ; Now reuse and adapt the code from OUL guys ! 84 ; Now reuse and adapt the code from OUL guys ! 85 ; TODO 36 86 37 87 ; That's all folks ! … … 41 91 42 92 ; Send a command to the ROM. The available commands are : 43 ERASE equ 0x8093 ;ERASE equ 0x80 44 94 IDENTIFY equ 0x90 45 95 BYTEPROG equ 0xA0 … … 48 98 ; Input: Commend to send in A register 49 99 send_command: 100 ; That code is shared with sector erase which has some tricks 101 call prepare_command 102 103 ; Select ROM 1 again and write the command to address 0xEAAA 104 DEC C 105 OUT (C),C 106 EX DE,HL 107 LD (HL), A 108 109 RET 110 111 prepare_command: 50 112 ; Select ROM 1 51 113 LD BC,0xDF01 … … 62 124 EX DE,HL 63 125 LD (HL), E 64 65 ; Select ROM 1 again and write the command to address 0xEAAA66 DEC C67 OUT (C),C68 EX DE,HL69 LD (HL), A70 126 71 127 RET
Note:
See TracChangeset
for help on using the changeset viewer.