git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/targets/z80/msxdos/global.s

      1         .OS_RESET       = 0x0000
      2         .LS_IO          = 0x0003
      3         .LS_DSK         = 0x0004
      4         .LS_INT_VECTOR  = 0x0038
      5         .LS_FCB0        = 0x005C
      6         .LS_FCB1        = 0x006C
      7         .LS_FILE_BUFFER = 0x0080
      8         .BDOS           = 0x0005
      9 
     10         .EXTBIO         = 0xFFCA
     11 
     12         ; MSX-DOS 1
     13         _TERM0          = 0x00  ; Program terminate
     14         _CONIN          = 0x01  ; Console input
     15         _CONOUT         = 0x02  ; Console output
     16         _AUXIN          = 0x03  ; Auxiliary input
     17         _AUXOUT         = 0x04  ; Auxiliary output
     18         _LSTOUT         = 0x05  ; Printer output
     19         _DIRIO          = 0x06  ; Direct console I/O
     20         _DIRIN          = 0x07  ; Direct console input
     21         _INNOE          = 0x08  ; Console input without echo
     22         _STROUT         = 0x09  ; String output
     23         _BUFIN          = 0x0A  ; Buffered line input
     24         _CONST          = 0x0B  ; Console status
     25         _CPMVER         = 0x0C  ; Return version number
     26         _DSKRST         = 0x0D  ; Disk reset
     27         _SELDSK         = 0x0E  ; Select disk
     28         _FOPEN          = 0x0F  ; Open file (FCB)
     29         _FCLOSE         = 0x10  ; Close file (FCB)
     30         _SFIRST         = 0x11  ; Search for first entry (FCB)
     31         _SNEXT          = 0x12  ; Search for next entry (FCB)
     32         _FDEL           = 0x13  ; Delete file (FCB)
     33         _RDSEQ          = 0x14  ; Sequential read (FCB)
     34         _WRSEQ          = 0x15  ; Sequential write (FCB)
     35         _FMAKE          = 0x16  ; Create file (FCB)
     36         _FREN           = 0x17  ; Rename file (FCB)
     37         _LOGIN          = 0x18  ; Get login vector
     38         _CURDRV         = 0x19  ; Get current drive
     39         _SETDTA         = 0x1A  ; Set disk transfer address
     40         _ALLOC          = 0x1B  ; Get allocation information
     41         _RDRND          = 0x21  ; Random read (FCB)
     42         _WRRND          = 0x22  ; Random write (FCB)
     43         _FSIZE          = 0x23  ; Get file size (FCB)
     44         _SETRND         = 0x24  ; Set random record (FCB)
     45         _WRBLK          = 0x26  ; Random block write (FCB)
     46         _RDBLK          = 0x27  ; Random block read (FCB)
     47         _WRZER          = 0x28  ; Random write with zero fill (FCB)
     48         _GDATE          = 0x2A  ; Get date
     49         _SDATE          = 0x2B  ; Set date
     50         _GTIME          = 0x2C  ; Get time
     51         _STIME          = 0x2D  ; Set time
     52         _VERIFY         = 0x2E  ; Set/reset verify flag
     53         _RDABS          = 0x2F  ; Absolute sector read
     54         _WRABS          = 0x30  ; Absolute sector write
     55 
     56         ; MSX-DOS2
     57         _DPARM          = 0x31  ; Get disk parameters
     58         _FFIRST         = 0x40  ; Find first entry
     59         _FNEXT          = 0x41  ; Find next entry
     60         _FNEW           = 0x42  ; Find new entry
     61         _OPEN           = 0x43  ; Open file handle
     62         _CREATE         = 0x44  ; Create file handle
     63         _CLOSE          = 0x45  ; Close file handle
     64         _ENSURE         = 0x46  ; Ensure file handle
     65         _DUP            = 0x47  ; Duplicate file handle
     66         _READ           = 0x48  ; Read from file handle
     67         _WRITE          = 0x49  ; Write to file handle
     68         _SEEK           = 0x4A  ; Move file handle pointer
     69         _IOCTL          = 0x4B  ; I/O control for devices
     70         _HTEST          = 0x4C  ; Test file handle
     71         _DELETE         = 0x4D  ; Delete file or subdirectory
     72         _RENAME         = 0x4E  ; Rename file or subdirectory
     73         _MOVE           = 0x4F  ; Move file or subdirectory
     74         _ATTR           = 0x50  ; Get/set file attributes
     75         _FTIME          = 0x51  ; Get/set file date and time
     76         _HDELETE        = 0x52  ; Delete file handle
     77         _HRENAME        = 0x53  ; Rename file handle
     78         _HMOVE          = 0x54  ; Move file handle
     79         _HATTR          = 0x55  ; Get/set file handle attributes
     80         _HFTIME         = 0x56  ; Get/set file handle date and time
     81         _GETDTA         = 0x57  ; Get disk transfer address
     82         _GETVFY         = 0x58  ; Get verify flag setting
     83         _GETCD          = 0x59  ; Get current directory
     84         _CHDIR          = 0x5A  ; Change current directory
     85         _PARSE          = 0x5B  ; Parse pathname
     86         _PFILE          = 0x5C  ; Parse filename
     87         _CHKCHR         = 0x5D  ; Check character
     88         _WPATH          = 0x5E  ; Get whole path string
     89         _FLUSH          = 0x5F  ; Flush disk buffers
     90         _FORK           = 0x60  ; Fork a child process
     91         _JOIN           = 0x61  ; Rejoin parent process
     92         _TERM           = 0x62  ; Terminate with error code
     93         _DEFAB          = 0x63  ; Define abort exit routine
     94         _DEFER          = 0x64  ; Define disk error handler routine
     95         _ERROR          = 0x65  ; Get previous error code
     96         _EXPLAIN        = 0x66  ; Explain error code
     97         _FORMAT         = 0x67  ; Format a disk
     98         _RAMD           = 0x68  ; Create or destroy RAM disk
     99         _BUFFER         = 0x69  ; Allocate sector buffers
    100         _ASSIGN         = 0x6A  ; Logical drive assignment
    101         _GENV           = 0x6B  ; Get environment item
    102         _SENV           = 0x6C  ; Set environment item
    103         _FENV           = 0x6D  ; Find environment item
    104         _DSKCHK         = 0x6E  ; Get/set disk check status
    105         _DOSVER         = 0x6F  ; Get MSX-DOS version number
    106         _REDIR          = 0x70  ; Get/set redirection status
    107 
    108         ; MSX_DOS ERROR CODES
    109         .NCOMP          = 0xFF  ; Incompatible disk
    110         .WRERR          = 0xFE  ; Write error
    111         .DISK           = 0xFD  ; Disk error
    112         .NRDY           = 0xFC  ; Not ready
    113         .VERFY          = 0xFB  ; Verify error
    114         .DATA           = 0xFA  ; Data error
    115         .RNF            = 0xF9  ; Sector not found
    116         .WPROT          = 0xF8  ; Write protected disk
    117         .UFORM          = 0xF7  ; Unformatted disk
    118         .NDOS           = 0xF6  ; Not a DOS disk
    119         .WDISK          = 0xF5  ; Wrong disk
    120         .WFILE          = 0xF4  ; Wrong disk for file
    121         .SEEK           = 0xF3  ; Seek error
    122         .IFAT           = 0xF2  ; Bad file allocation table
    123         .NOUPB          = 0xF1  ; --
    124         .IFORM          = 0xF0  ; Cannot format this drive
    125         .INTER          = 0xDF  ; Internal error
    126         .NORAM          = 0xDE  ; Not enough memory
    127         .IBDOS          = 0xDC  ; Invalid MSX-DOS call
    128         .IDRV           = 0xDB  ; Invalid drive
    129         .IFNM           = 0xDA  ; Invalid filename
    130         .IPATH          = 0xD9  ; Invalid pathname
    131         .PLONG          = 0xD8  ; Pathname too long
    132         .NOFIL          = 0xD7  ; File not found
    133         .NODIR          = 0xD6  ; Directory not found
    134         .DRFUL          = 0xD5  ; Root directory full
    135         .DKFUL          = 0xD4  ; Disk full
    136         .DUPF           = 0xD3  ; Duplicate filename
    137         .DIRE           = 0xD2  ; Invalid directory move
    138         .FILRO          = 0xD1  ; Read only file
    139         .DIRNE          = 0xD0  ; Directory not empty
    140         .IATTR          = 0xCF  ; Invalid attributes
    141         .DOT            = 0xCE  ; Invalid . or .. operation
    142         .SYSX           = 0xCD  ; System file exists
    143         .DIRX           = 0xCC  ; Directory exists
    144         .FILEX          = 0xCB  ; File exists
    145         .FOPEN          = 0xCA  ; File already in use
    146         .OV64K          = 0xC9  ; Cannot transfer above 64K
    147         .FILE           = 0xC8  ; File allocation error
    148         .EOF            = 0xC7  ; End of file
    149         .ACCV           = 0xC6  ; File access violation
    150         .IPROC          = 0xC5  ; Invalid process id
    151         .NHAND          = 0xC4  ; No spare file handles
    152         .IHAND          = 0xC3  ; Invalid file handle
    153         .NOPEN          = 0xC2  ; File handle not open
    154         .IDEV           = 0xC1  ; Invalid device operation
    155         .IENV           = 0xC0  ; Invalid environment string
    156         .ELONG          = 0xBF  ; Environment string too long
    157         .IDATE          = 0xBE  ; Invalid date
    158         .ITIME          = 0xBD  ; Invalid time
    159         .RAMDX          = 0xBC  ; RAM disk (drive H ) already exists
    160         .NRAMD          = 0xBB  ; RAM disk does not exist
    161         .HDEAD          = 0xBA  ; File handle has been deleted
    162         .EOL            = 0xB9  ; Internal error. Should never occur
    163         .ISBFN          = 0xB8  ; Invalid sub-function number
    164         .STOP           = 0x9F  ; Ctrl-STOP pressed
    165         .CTRLC          = 0x9E  ; Ctrl-C pressed
    166         .ABORT          = 0x9D  ; Disk operation aborted
    167         .OUTERR         = 0x9C  ; Error on standard output
    168         .INERR          = 0x9B  ; Error on standard input
    169         .BADCOM         = 0x8F  ; Wrong version of COMMAND
    170         .BADCM          = 0x8E  ; Unrecognized command
    171         .BUFUL          = 0x8D  ; Command too long
    172         .OKCMD          = 0x8C  ; --
    173         .IPARM          = 0x8B  ; Invalid parameter
    174         .INP            = 0x8A  ; Too many parameters
    175         .NOPAR          = 0x89  ; Missing parameter
    176         .IOPT           = 0x88  ; Invalid option
    177         .BADNO          = 0x87  ; Invalid number
    178         .NOHELP         = 0x86  ; File for HELP not found
    179         .BADVER         = 0x85  ; Wrong version of MSX-DOS
    180         .NOCAT          = 0x84  ; Cannot concatenate destination file
    181         .BADEST         = 0x83  ; Cannot create destination file
    182         .COPY           = 0x82  ; File cannot be copied onto itself
    183         .OVDEST         = 0x81  ; Cannot overwrite previous destination file
    184 
    185         .VDP_VRAM       = 0x4000
    186         .VDP_TILEDATA0  = 0x4000
    187         .VDP_TILEDATA1  = 0x4800
    188         .VDP_TILEDATA2  = 0x5000
    189         .VDP_COLORDATA0 = 0x6000
    190         .VDP_COLORDATA1 = 0x6800
    191         .VDP_COLORDATA2 = 0x7000
    192 
    193         .VDP_SPRDATA0   = 0x7800
    194 
    195         .VDP_TILEMAP    = 0x5C00
    196         .VDP_CRAM       = 0xC000
    197         .VDP_SAT        = 0x5B00
    198 
    199         .VDP_SAT_TERM   = 0xD0
    200 
    201         .VDP_VCOUNTER   = 0x7E
    202         .VDP_PSG        = 0x7F
    203         .VDP_HCOUNTER   = 0x7F
    204 
    205         .VDP_DATA       = 0x98
    206         .VDP_CMD        = 0x99
    207         .VDP_STAT       = 0x99
    208 
    209         .STATF_INT_VBL  = 0b10000000
    210         .STATF_9_SPR    = 0b01000000
    211         .STATF_SPR_COLL = 0b00100000
    212 
    213         .VDP_REG_MASK   = 0b10000000
    214         .VDP_R0         = 0b10000000
    215 
    216         .R0_DEFAULT     = 0b00000000
    217         .R0_CB_OUTPUT   = 0b00000000
    218         .R0_CB_INPUT    = 0b01000000
    219         .R0_IE2_OFF     = 0b00000000
    220         .R0_IE2         = 0b00100000
    221         .R0_IE1_OFF     = 0b00000000
    222         .R0_IE1         = 0b00010000
    223         .R0_SCR_MODE1   = 0b00000000
    224         .R0_SCR_MODE2   = 0b00000010
    225         .R0_ES_OFF      = 0b00000000
    226         .R0_ES          = 0b00000001
    227 
    228         .VDP_R1         = 0b10000001
    229 
    230         .R1_DEFAULT     = 0b10000000
    231         .R1_DISP_OFF    = 0b00000000
    232         .R1_DISP_ON     = 0b01000000
    233         .R1_IE_OFF      = 0b00000000
    234         .R1_IE          = 0b00100000
    235         .R1_SCR_MODE1   = 0b00010000
    236         .R1_SCR_MODE2   = 0b00000000
    237         .R1_SCR_MODE3   = 0b00000000
    238         .R1_SPR_8X8     = 0b00000000
    239         .R1_SPR_16X16   = 0b00000010
    240         .R1_SPR_MAG     = 0b00000001
    241         .R1_SPR_MAG_OFF = 0b00000000
    242 
    243         .VDP_R2         = 0b10000010
    244 
    245         .R2_MAP_0x1C00  = 0x07
    246 
    247         .VDP_R3         = 0b10000011
    248         .VDP_R4         = 0b10000100
    249         .VDP_R5         = 0b10000101
    250 
    251         .R5_SAT_0x1B00  = 0x36
    252         .R5_SAT_MASK    = 0b10000001
    253 
    254         .VDP_R6         = 0b10000110
    255 
    256         .VDP_R7         = 0b10000111
    257         .VDP_RBORDER    = 0b10000111
    258 
    259         .R7_COLOR_MASK  = 0b11110000
    260 
    261         .VDP_R8         = 0b10001000
    262 
    263         .VDP_R9         = 0b10001001
    264 
    265         .VDP_R10        = 0b10001010
    266 
    267         .JOYPAD_COUNT   = 1
    268 
    269         .UP             = 0b00100000
    270         .DOWN           = 0b01000000
    271         .LEFT           = 0b00010000
    272         .RIGHT          = 0b10000000
    273         .A              = 0b00000001
    274         .B              = 0b00000100
    275         .SELECT         = 0b00001000
    276         .START          = 0b00000010
    277 
    278         .KBD_SELECT_ROW = 0xAA
    279         .KBD_INPUT      = 0xA9
    280 
    281         .FMADDRESS      = 0xF0
    282         .FMDATA         = 0xF1
    283         .AUDIOCTRL      = 0xF2
    284 
    285         .MAP_FRAME0     = 0xfffc
    286         .MAP_FRAME1     = 0xfffd
    287         .MAP_FRAME2     = 0xfffe
    288         .MAP_FRAME3     = 0xffff
    289 
    290         .SYSTEM_NTSC    = 0x00
    291         .SYSTEM_PAL     = 0x01
    292 
    293         .CPU_CLOCK      = 3579545
    294 
    295         ;; GBDK library screen modes
    296 
    297         .T_MODE         = 0x02  ; Text mode (bit 2)
    298         .T_MODE_OUT     = 0x02  ; Text mode output only
    299         .T_MODE_INOUT   = 0x03  ; Text mode with input
    300         .M_NO_SCROLL    = 0x04  ; Disables scrolling of the screen in text mode
    301         .M_NO_INTERP    = 0x08  ; Disables special character interpretation
    302 
    303         ;; Screen dimentions in tiles
    304 
    305         .SCREEN_X_OFS   = 0
    306         .SCREEN_Y_OFS   = 0
    307         .SCREEN_WIDTH   = 32
    308         .SCREEN_HEIGHT  = 24
    309         .VDP_MAP_HEIGHT = 24
    310         .VDP_MAP_WIDTH  = 32
    311 
    312         ;; Interrupt flags
    313 
    314         .VBL_IFLAG      = 0x01
    315         .LCD_IFLAG      = 0x02
    316 
    317         ; characters
    318         .CR             = 0x0A
    319         .SPACE          = 0x00
    320 
    321         ;; C related
    322         ;; Overheap of a banked call.  Used for parameters
    323         ;;  = ret + real ret + bank
    324 
    325         .BANKOV         = 5
    326 
    327         ;; Main user routine
    328         .globl  _main
    329 
    330         ;; interrupt handler
    331         .globl _INT_ISR
    332 
    333         ;; Macro definitions
    334 
    335 .macro CALL_BDOS fn
    336         ld c, fn
    337         call .BDOS
    338 .endm
    339 
    340 .macro JP_BDOS fn
    341         ld c, fn
    342         jp .BDOS
    343 .endm
    344 
    345 .macro VDP_WRITE_DATA regH regL
    346         ld a, regL
    347         out (#.VDP_DATA), a
    348         ld a, regH
    349         inc hl
    350         dec hl
    351         out (#.VDP_DATA), a
    352 .endm
    353 
    354 .macro VDP_WRITE_CMD regH regL
    355         ld a, regL
    356         di
    357         out (#.VDP_CMD), a
    358         ld a, regH
    359         ei
    360         out (#.VDP_CMD), a
    361 .endm
    362 
    363 .macro VDP_DELAY ?lbl
    364         nop
    365         jr lbl
    366 lbl:
    367 .endm
    368 
    369 .macro VDP_CANCEL_INT
    370         in a, (.VDP_STAT)       ; cancel pending VDP interrupts
    371 .endm
    372 
    373 .macro WRITE_VDP_CMD_HL
    374         MSX_WRITE_VDP_CMD h, l
    375 .endm
    376 
    377 .macro WRITE_VDP_DATA_HL
    378         MSX_WRITE_VDP_DATA h, l
    379 .endm
    380 
    381 .macro CALL_HL
    382         call ___sdcc_call_hl
    383 .endm
    384 
    385 .macro DISABLE_VBLANK_COPY
    386         ld hl, #__shadow_OAM_OFF
    387         inc (hl)
    388 .endm
    389 
    390 .macro ENABLE_VBLANK_COPY
    391         ld hl, #__shadow_OAM_OFF
    392         dec (hl)
    393 .endm
    394 
    395 .macro ADD_A_REG16 regH regL
    396         add regL
    397         ld regL, a
    398         adc regH
    399         sub regL
    400         ld regH, a
    401 .endm
    402 
    403 .macro MUL_DE_BY_A_RET_HL ?lbl1 ?lbl2
    404         ; Multiply DE by A, return result in HL; preserves: BC
    405         ld hl, #0
    406 lbl1:
    407         srl a
    408         jp nc, lbl2
    409         add hl, de
    410 lbl2:
    411         sla e
    412         rl d
    413         or a
    414         jp nz, lbl1
    415 .endm
    416 
    417 .macro DIV_PART divident divisor ?lbl
    418         rl divident
    419         rla
    420         sub divisor
    421         jr  nc, lbl
    422         add divisor
    423 lbl:
    424 .endm
    425 .macro FAST_MOD8 divident divisor
    426         ; returns modulus in A
    427         .rept 8
    428                 DIV_PART divident divisor
    429         .endm
    430 .endm

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.