library
library
fat32 | joystick | keyboard | sdcard | spi | uart | util | vdp |
fat32
fat_chdir | fat_close | fat_fopen | fat_fread_byte | fat_fread_vollgas | fat_fseek | fat_get_root_and_pwd | fat_mkdir | fat_mount | fat_opendir | fat_read_direntry | fat_readdir | fat_rmdir | fat_unlink | fat_update_direntry | fat_write_byte |
fat_chdir
change current directory
- In
- A, low byte of pointer to zero terminated string with the file path
X, high byte of pointer to zero terminated string with the file path - Out
- C, C=0 on success (A=0), C=1 and A=
otherwise
X, index into fd_area of the opened directory (which is FD_INDEX_CURRENT_DIR)
fat_close
close file, update dir entry and free file descriptor quietly
- In
- X, index into fd_area of the opened file
- Out
- C, 0 on success, 1 on error
A, error code
fat_fopen
open file
- In
- A, low byte of pointer to zero terminated string with the file path
X, high byte of pointer to zero terminated string with the file path
Y, file mode constants O_RDONLY = $01, O_WRONLY = $02, O_RDWR = $03, O_CREAT = $10, O_TRUNC = $20, O_APPEND = $40, O_EXCL = $80 - Out
- C, 0 on success, 1 on error
A, error code
X, index into fd_area of the opened file
fat_fread_byte
read byte from file
- In
- X, offset into fd_area
- Out
- C=0 on success and A=received byte, C=1 on error and A=error code or C=1 and A=0 (EOK) if EOF is reached
fat_fread_vollgas
read the file denoted by given file descriptor (X) until EOF and store data at given address (A/Y)
- In
- X - offset into fd_area
A/Y - pointer to target address - Out
- C=0 on success, C=1 on error and A=error code or C=1 and A=0 (EOK) if EOF is reached
fat_fseek
seek n bytes within file denoted by the given FD
- In
- X - offset into fd_area
A/Y - pointer to seek_struct - @see fat32.inc - Out
- C=0 on success (A=0), C=1 and A=
or C=1 and A=0 (EOK) if EOF reached
fat_get_root_and_pwd
get current directory
- In
- A, low byte of address to write the current work directory string into
Y, high byte address to write the current work directory string into
X, size of result buffer pointet to by A/X - Out
- C, 0 on success, 1 on error
A, error code
fat_mkdir
create directory denoted by given path in A/X
- In
- A, low byte of pointer to directory string
X, high byte of pointer to directory string - Out
- C, 0 on success, 1 on error
A, error code
fat_mount
mount fat32 file system
- Out
- C, 0 on success, 1 on error
A, error code
fat_opendir
open directory by given path starting from directory given as file descriptor
- In
- A/X - pointer to string with the file path
- Out
- C, C=0 on success (A=0), C=1 and A=
otherwise
X, index into fd_area of the opened directory
fat_read_direntry
read the block with the directory entry of the given file descriptor, dirptr is adjusted accordingly
- In
- X - file descriptor of the file the directory entry should be read
- Out
- C - C=0 on success (A=0), C=1 and A=
otherwise
dirptr pointing to the corresponding directory entry of type F32DirEntry
fat_readdir
readdir expects a pointer in A/Y to store the next F32DirEntry structure representing the next FAT32 directory entry in the directory stream pointed of directory X.
- In
- X - file descriptor to fd_area of the directory
A/Y - pointer to target buffer which must be .sizeof(F32DirEntry) - Out
- C - C = 0 on success (A=0), C = 1 and A =
otherwise. C=1/A=EOK if end of directory is reached
fat_rmdir
delete a directory entry denoted by given path in A/X
- In
- A, low byte of pointer to directory string
X, high byte of pointer to directory string - Out
- C, 0 on success, 1 on error
A, error code
fat_unlink
unlink (delete) a file denoted by given path in A/X
- In
- A, low byte of pointer to zero terminated string with the file path
X, high byte of pointer to zero terminated string with the file path - Out
- C, C=0 on success (A=0), C=1 and A=
otherwise
fat_update_direntry
update direntry given as pointer (A/Y) to FAT32 directory entry structure for file fd (X).
- In
- X - file descriptor to fd_area of the file
A/Y - pointer to direntry buffer with updated direntry data of type F32DirEntry - Out
- C - C = 0 on success (A=0), C = 1 and A =
otherwise. C=1/A=EOK if end of directory is reached
fat_write_byte
write byte to file
- In
- A, byte to write
X, offset into fs area - Out
- C, 0 on success, 1 on error
joystick
joystick_detect | joystick_read |
joystick_detect
detect joystick
- Out
- Z, Z=1 no joystick detected, Z=0 joystick detected, port in A
A, detected joystick port, JOY_PORT1 or JOY_PORT2
joystick_read
read state of specified joystick
- Out
- A, joystick button state - bit 0-4
keyboard
fetchkey
fetch byte from keyboard controller
- Out
- A, fetched key / error code
C, 1 - key was fetched, 0 - nothing fetched
getkey
get byte from keyboard buffer
- Out
- A, fetched key
C, 1 - key was fetched, 0 - nothing fetched
sdcard
sd_busy_wait | sd_cmd | sd_deselect_card | sd_read_block | sd_select_card | sd_write_block | sdcard_init |
sd_busy_wait
wait while sd card is busy
- Out
- C, C = 0 on success, C = 1 on error (timeout)
- Clobbers
- A,X,Y
sd_cmd
send command to sd card
- In
- A, command byte
sd_cmd_param, command parameters - Out
- A, SD Card R1 status byte
- Clobbers
- A,X,Y
sd_deselect_card
Read block from SD Card
- Out
- A, error code
C, 0 - success, 1 - error - Clobbers
- X
sd_read_block
Read block from SD Card
- In
- lba_addr, LBA address of block
sd_blkptr, target adress for the block data to be read - Out
- A, error code
C, 0 - success, 1 - error - Clobbers
- A,X,Y
sd_select_card
select sd card, pull CS line to low with busy wait
- Out
- C, C = 0 on success, C = 1 on error (timeout)
- Clobbers
- A,X,Y
sd_write_block
Write block to SD Card
- In
- lba_addr, LBA address of block
sd_blkptr, target adress for the block data to be read - Out
- A, error code
C, 0 - success, 1 - error - Clobbers
- A,X,Y
sdcard_init
initialize sd card in SPI mode
- Out
- Z,1 on success, 0 on error
A, error code - Clobbers
- A,X,Y
spi
spi_deselect | spi_r_byte | spi_rw_byte | spi_select_device |
spi_deselect
deselect all SPI devices
spi_r_byte
read byte via SPI
- Out
- A, received byte
- Clobbers
- A,X
spi_rw_byte
transmit byte via SPI
- In
- A, byte to transmit
- Out
- A, received byte
- Clobbers
- A,X,Y
spi_select_device
select spi device given in A. the method is aware of the current processor state, especially the interrupt flag
- In
- ; A, spi device, one of devices see spi.inc
- Out
- Z = 1 spi for given device could be selected (not busy), Z=0 otherwise
uart
uart_init | uart_rx | uart_rx_nowait | uart_tx |
uart_init
initialize UART with parameters from nvram
- Clobbers
- A,X,Y
uart_rx
receive byte
- Out
- A, received byte
uart_rx_nowait
receive byte, no wait
- Out
- A, received byte
C, 0 - no byte received, 1 - received byte
uart_tx
send byte
- In
- A, byte to send
util
atoi | b2ad | b2ad2 | bin2dual | hexout | hextodec | strout |
atoi
convert ascii digit to binary
- In
- A, value to convert
- Out
- A, binary number
b2ad
output 8bit value as 2 digit decimal
- In
- A, value to output
b2ad2
output 8bit value as 3 digit decimal
- In
- A, value to output
bin2dual
output 8bit value as binary string
- In
- A, value to output
hexout
output 8bit value as hex
- In
- A, value to convert
hextodec
8bit hex to decimal converter
- In
- A, value to convert
- Out
- A, ones
X, tens
Y, hundreds
strout
Output string on active output device
- In
- A, lowbyte of string address
X, highbyte of string address
vdp
gfx_circle | gfx_line | gfx_plot | gfx_point | gfx_rectangle | ppm_load_image | vdp_bgcolor | vdp_cmd_hmmv | vdp_fill | vdp_fills | vdp_gfx1_blank | vdp_gfx1_on | vdp_gfx7_set_pixel_direct | vdp_init_reg | vdp_mc_blank | vdp_mc_init_screen | vdp_mc_on | vdp_mc_set_pixel | vdp_memcpy | vdp_memcpys | vdp_mode2_blank | vdp_mode2_on | vdp_mode2_set_pixel | vdp_mode3_on | vdp_mode6_blank | vdp_mode6_on | vdp_mode6_set_pixel | vdp_mode7_blank | vdp_mode7_on | vdp_mode7_set_pixel | vdp_mode_sprites_off | vdp_set_reg | vdp_text_blank | vdp_text_on | vdp_wait_cmd |
gfx_circle
draw circle
- In
- A/Y - pointer to circle_t struct
gfx_line
draw line according to data in given line struct
- In
- A/Y ptr to line_t struct
gfx_plot
plot pixel
- In
- A/Y - pointer to plot_t struct
gfx_point
read pixel value
- In
- A/Y - pointer to plot_t struct
- Out
- Y - color of pixel at given plot_t
gfx_rectangle
draw a rectangle according to data in given rectangle struct
- In
- A/Y ptr to rectangle_t struct
ppm_load_image
- In
- A/X file name to load
Y vdp vram page to load ppm into - either 0 for address $00000 or 1 for address $10000 - Out
- C=0 success and image loaded to vram (mode 7), C=1 otherwise with A/X error code where X ppm specific error, A i/o specific error
vdp_bgcolor
- In
- A - color
vdp_cmd_hmmv
execute highspeed memory move (vdp/vram) or fill
- In
- A/X - ptr to rectangle coordinates (4 word with x1,y1, len x, len y)
Y - color to fill in (reg #44)
vdp_fill
fill vdp VRAM with given value page wise
- In
- A - byte to fill
X - amount of 256byte blocks (page counter)
vdp_fills
fill vdp VRAM with given value
- In
- A - value to write
X - amount of bytes
vdp_gfx1_blank
vdp_gfx1_on
gfx mode 1 - 32x24 character mode, 16 colors with same color for 8 characters in a block
vdp_gfx7_set_pixel_direct
- In
- X - x coordinate [0..ff]
Y - y coordinate [0..bf]
A - color GRB [0..ff] as 332
vdp_init_reg
setup video registers upon given table starting from register #R.X down to #R0
- In
- X - length of init table, corresponds to video register to start R#+X - e.g. X=10 start with R#10
A/Y - pointer to vdp init table
vdp_mc_blank
blank multi color mode, set all pixel to black
- In
- A - color to blank
vdp_mc_init_screen
init mc screen
vdp_mc_on
gfx multi color mode - 4x4px blocks where each can have one of the 15 colors
vdp_mc_set_pixel
set pixel to mc screen - VRAM ADDRESS = 8(INT(X DIV 2)) + 256(INT(Y DIV 8)) + (Y MOD 8)
- In
- X - x coordinate [0..3f]
Y - y coordinate [0..2f]
A - color [0..f]
vdp_memcpy
copy data from host memory denoted by pointer (A/Y) to vdp VRAM (page wise). the VRAM address must be setup beforehand e.g. with macro vdp_vram_w
- In
- X - amount of 256byte blocks (page counter)
A/Y - pointer to source data
vdp_memcpys
copy memory to vdp VRAM page wise
- In
- X - amount of bytes to copy
A/Y - pointer to data
vdp_mode2_blank
blank gfx mode 2 with
- In
- A - color to fill [0..f]
vdp_mode2_on
gfx 2 - each pixel can be addressed - e.g. for image
vdp_mode2_set_pixel
set pixel to gfx2 mode screen - VRAM ADDRESS = 8(INT(X DIV 8)) + 256(INT(Y DIV 8)) + (Y MOD 8)
- In
- X - x coordinate [0..ff]
Y - y coordinate [0..bf]
A - color [0..f]
vdp_mode3_on
mode 3 on
vdp_mode6_blank
blank gfx mode 6 with given color
- In
- Y - color to fill 4|4 Bit
vdp_mode6_on
gfx 6 - 512x192/212px, 16colors, sprite mode 2
vdp_mode6_set_pixel
set pixel to gfx6 mode screen - VRAM ADDRESS = 8(INT(X DIV 2)) + 256(INT(Y DIV 8)) + (Y MOD 8)
- In
- X - x coordinate [0..ff]
Y - y coordinate [0..bf]
A - color [0..f] and bit 7 MSB x coordinate
vdp_mode7_blank
blank gfx mode 7 with
- In
- Y - color to fill in GRB (3+3+2)
vdp_mode7_on
gfx 7 - each pixel can be addressed - e.g. for image
vdp_mode7_set_pixel
VRAM ADDRESS = .X + 256*.Y
- In
- X - x coordinate [0..ff]
Y - y coordinate [0..bf]
. A - color [0..ff] as GRB 332 (green bit 7-5, red bit 4-2, blue bit 1-0)
vdp_mode_sprites_off
vdp_set_reg
set value to vdp register
- In
- A - value
Y - register
vdp_text_blank
text mode blank screen and color vram
vdp_text_on
text mode - 40x24/80x24 character mode, 2 colors
- In
- A - color settings (#R07)
vdp_wait_cmd
wait until a pending command has been finished