;license:MIT ;(c) 2018 by 4am ; ; common assembler macros ; ; for functions that take parameters on the stack ; set (PARAM) to point to the parameters and ; move the stack pointer to the first byte after the parameters ; clobbers A,X,Y !macro PARAMS_ON_STACK .bytes { pla sta PARAM pla tax stx PARAM+1 lda #.bytes clc adc PARAM tay bcc + inx + txa pha tya pha } ; for functions that take parameters on the stack ; load a 16-bit value from the parameters on the stack into A (low) and Y (high) ; (assumes PARAMS_ON_STACK was used first) !macro LDPARAM .offset { ldy #.offset lda (PARAM),y pha iny lda (PARAM),y tay pla } ; load the address of .ptr into A (low) and Y (high) !macro LDADDR .ptr { lda #<.ptr ldy #>.ptr } ; load a 16-bit value into A (low) and Y (high) !macro LDAY .ptr { lda .ptr ldy .ptr+1 } ; store a 16-bit value from A (low) and Y (high) !macro STAY .ptr { sta .ptr sty .ptr+1 } ; use BIT to swallow the following 1-byte opcode !macro HIDE_NEXT_BYTE { !byte $24 } ; use BIT to swallow the following 2-byte opcode !macro HIDE_NEXT_2_BYTES { !byte $2C } ; various language card configurations !macro READ_RAM1_WRITE_RAM1 { bit $C08B bit $C08B } !macro READ_ROM_WRITE_RAM1 { bit $C089 bit $C089 } !macro READ_ROM_NO_WRITE { bit $C082 } !macro LOAD_FILE .subdirectory, .filename { jsr ResetPath +LDADDR .subdirectory jsr AddToPath +LDADDR kPathSeparator jsr AddToPath +LDAY .filename jsr AddToPath jsr LoadFile !word gPathname } !macro LOAD_PATH .subdirectory { jsr ResetPath +LDADDR .subdirectory jsr AddToPath +LDADDR kPathSeparator jsr AddToPath } !macro LOAD_FILE_IMM .filename { +LDAY .filename jsr AddToPath jsr LoadFile !word gPathname }