source: avrstuff/CPC stuff/gordon/manager/gordon.z80@ 7dcccbc

main
Last change on this file since 7dcccbc was 7dcccbc, checked in by Adrien Destugues <pulkomandy@…>, 12 years ago

Add WIP code for the manager (and ROM testing)

git-svn-id: svn://pulkomandy.tk/avrstuff@78 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

  • Property mode set to 100644
File size: 1.8 KB
Line 
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 :
43ERASE equ 0x80
44IDENTIFY equ 0x90
45BYTEPROG equ 0xA0
46RESET equ 0xF0
47
48; Input: Commend to send in A register
49send_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
75printhex
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
83PRNHEX1 ;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;
Note: See TracBrowser for help on using the repository browser.