Changeset b9dcc8b in avrstuff


Ignore:
Timestamp:
Dec 2, 2012, 10:27:14 PM (11 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
7d19206
Parents:
9b0bfb3
Message:

Handle call parameters to allow selecting the rom number and file.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CPC stuff/gordon/manager/gordon.z80

    r9b0bfb3 rb9dcc8b  
    99putc    EQU     0xBB5A
    1010screenmem       EQU     0xBC08
     11fopen   EQU     0xBC77
     12fread   EQU 0xBC83
     13fclose  EQU     0xBC7A
    1114
    1215
     
    2326; This is the entry point when running as a standalone file
    2427_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
    2555        ; Ask the user to allow us to write to the flash memory
    2656        LD HL,MSG_WRITE_START
     
    2959        ; From there on, writing is enabled. This is ok as long as we don't
    3060        ; connect a writable ROM ! When we do, we have to make sure NOTHING
    31         ; is read written from 8000-FFFF because the MegaFlash hardware
     61        ; is read/written from 8000-FFFF because the MegaFlash hardware
    3262        ; doesn't decode A14 and will answer for the whole 32k range. This
    3363        ; means, no use of firmware jumpblocks, and the stack needs to be
     
    102132        CALL screenmem
    103133
    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
    121135        ; TODO cleanly get out (and handle both calls by RUN and CALL)
    122         JR $
     136        RET
     137
     138
     139params_error
     140        LD HL,MSG_HELP
     141        CALL puts
     142        JR _exit
    123143
    124144
     
    137157       
    138158        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
    140160        OUT (C),C
    141161
     
    180200; Ok, now that we erased the 4 sectors we needed, we can write data to them
    181201        LD HL, 0xC000
    182         LD IX, 0x2000
     202        LD IY, 0x2000
    183203PROGRAM
    184204        PUSH HL
     
    190210
    191211        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,(IX + 0)
     212        LD C,(IX+0) ; ROM number to write
     213        OUT (C),C
     214
     215        LD A,(IY + 0)
    196216        LD (HL),A       ; Write occurs here. Need to wait 20 NOPs before next
    197217                ; operation on ROM. Our code is slow enough already !
    198218
    199         INC IX
     219        INC IY
    200220        INC HL
    201221
     
    216236CHECKBLANK
    217237        ; TODO select the right ROM
    218         LD BC,0xDF05
     238        LD B,0xDF
     239        LD C,(IX+0)
    219240        OUT (C),C
    220241       
     
    307328
    308329
    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 
    339330; -----------------------------------------------------------------------------
    340331; Messages
     
    343334MSG_ERASE_ERR   string "Erasing memory failed at address "
    344335MSG_WRITE_OK    string "Success!\r\n"
     336MSG_HELP                string "CALL &1800,\"filename.rom\",nn\r\n"
    345337
    346338; -----------------------------------------------------------------------------
     
    376368
    377369
     370; Dump some bytes from beginning of ROM 5
     371DUMP
     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
     390plop
     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.