[7dcccbc] | 1 | ; FLASH GORDON driver
|
---|
| 2 | ; Copyright 2012, Adrien Destugues <pulkomandy@gmail.com>
|
---|
| 3 | ; This program is distributed under the terms of the MIT licence
|
---|
| 4 |
|
---|
| 5 | ; Start here.
|
---|
| 6 | DI
|
---|
| 7 |
|
---|
| 8 | ; Move the screen to $8000 or $0000 so we can display things to the user, while
|
---|
| 9 | ; C000 will write to the ROM and 4000 will hold the data to write... That could
|
---|
| 10 | ; get a bit messy so maybe we will need to use the screen at 4000 as a buffer
|
---|
| 11 | ; for the ROM data as well. Or just use a bank for that ?
|
---|
| 12 |
|
---|
| 13 | ; Map the ROM in
|
---|
| 14 | ; TODO
|
---|
| 15 |
|
---|
| 16 | ; ask the user to enable writing
|
---|
| 17 | ; TODO
|
---|
| 18 |
|
---|
| 19 | ; Check if we can read the ROM type
|
---|
| 20 | LD A, 0x90
|
---|
| 21 | CALL send_command
|
---|
| 22 |
|
---|
| 23 | LD HL, 0xC000
|
---|
| 24 |
|
---|
| 25 | LD A,(HL)
|
---|
| 26 | CALL printhex
|
---|
| 27 | INC L
|
---|
| 28 | LD A,(HL)
|
---|
| 29 | CALL printhex
|
---|
| 30 |
|
---|
| 31 | ; We should get 0x8F 87
|
---|
| 32 | ; TODO check that before continuing with writing the data
|
---|
| 33 | JR $
|
---|
| 34 |
|
---|
| 35 | ; Now reuse and adapt the code from OUL guys !
|
---|
| 36 |
|
---|
| 37 | ; That's all folks !
|
---|
| 38 | RET
|
---|
| 39 |
|
---|
| 40 | ; Helper routines -----------------------------------------------------
|
---|
| 41 |
|
---|
| 42 | ; Send a command to the ROM. The available commands are :
|
---|
| 43 | ERASE equ 0x80
|
---|
| 44 | IDENTIFY equ 0x90
|
---|
| 45 | BYTEPROG equ 0xA0
|
---|
| 46 | RESET equ 0xF0
|
---|
| 47 |
|
---|
| 48 | ; Input: Commend to send in A register
|
---|
| 49 | send_command:
|
---|
| 50 | ; Select ROM 1
|
---|
| 51 | LD BC,0xDF01
|
---|
| 52 | LD HL,0xD555
|
---|
| 53 | LD DE,0xEAAA
|
---|
| 54 |
|
---|
| 55 | ; Select ROM 1 and write 0xAA to address 0xD555
|
---|
| 56 | OUT (C),C
|
---|
| 57 | LD (HL),E
|
---|
| 58 |
|
---|
| 59 | ; Select ROM 2 and write 0x55 to address 0xEAAA
|
---|
| 60 | INC C
|
---|
| 61 | OUT (C),C
|
---|
| 62 | EX DE,HL
|
---|
| 63 | LD (HL), E
|
---|
| 64 |
|
---|
| 65 | ; Select ROM 1 again and write the command to address 0xEAAA
|
---|
| 66 | DEC C
|
---|
| 67 | OUT (C),C
|
---|
| 68 | EX DE,HL
|
---|
| 69 | LD (HL), A
|
---|
| 70 |
|
---|
| 71 | RET
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | ; Print value of A, as 2 hex digits
|
---|
| 75 | printhex
|
---|
| 76 | PUSH AF
|
---|
| 77 | RRA
|
---|
| 78 | RRA
|
---|
| 79 | RRA
|
---|
| 80 | RRA ;divise A par 8
|
---|
| 81 | CALL PRNHEX1 ;affiche le premier morceau
|
---|
| 82 | POP AF ;r{cup la valeur originale pour la suit
|
---|
| 83 | PRNHEX1 ;affiche la valeur de A sur 1 chiffre
|
---|
| 84 | ;affiche A sur 1 chiffre en Hexa
|
---|
| 85 | AND 0xF ;ne prend que les unit{s
|
---|
| 86 | OR A
|
---|
| 87 | DAA ;convertit en d{cimal
|
---|
| 88 | ADD A,0xF0 ;ajoute 240
|
---|
| 89 | ADC A,0x40 ;ajoute 64+le carry (si >15)
|
---|
| 90 | ;on a le code ascii du chiffre @ afficher
|
---|
| 91 | JP 0xBB5A ;call-ret
|
---|
| 92 | ;
|
---|