Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef PSEUDOOPS_ASM
- #define PSEUDOOPS_ASM
- ;pseudoOps.asm
- #define _SCRATCH_A 0xf0
- #define _SCRATCH_B 0xf1
- #define _SCRATCH_C 0xf2
- ;flags
- #define sen tra s && ora #,0x80 && tar s
- #define seo tra s && ora #,0x40 && tar s
- #define sed tra s && ora #,0x20 && tar s
- #define seL tra s && ora #,0x10 && tar s
- #define see tra s && ora #,0x08 && tar s
- #define sel tra s && ora #,0x04 && tar s
- #define sez tra s && ora #,0x02 && tar s
- #define sec tra s && ora #,0x01 && tar s
- #define cln tra s && and #,0x7f && tar s
- #define clo tra s && and #,0xbf && tar s
- #define cld tra s && and #,0xdf && tar s
- #define clL tra s && and #,0xef && tar s
- #define cle tra s && and #,0xf7 && tar s
- #define cll tra s && and #,0xfb && tar s
- #define clz tra s && and #,0xfd && tar s
- #define clc tra s && and #,0xfe && tar s
- #define brk hcf
- ;bnz (put expression after or it won't work)
- #define bns tra s && and #,0x80 && bnz
- #define bos tra s && and #,0x40 && bnz
- #define bds tra s && and #,0x20 && bnz
- #define bLs tra s && and #,0x10 && bnz
- #define bes tra s && and #,0x08 && bnz
- #define beq bes
- #define bls tra s && and #,0x04 && bnz
- #define blt bls
- #define bzs tra s && and #,0x02 && bnz
- #define bcs tra s && and #,0x01 && bnz
- #define bnc tra s && and #,0x80 && xor #,0x80 && bnz
- #define boc tra s && and #,0x40 && xor #,0x40 && bnz
- #define bdc tra s && and #,0x20 && xor #,0x20 && bnz
- #define bLc tra s && and #,0x10 && xor #,0x10 && bnz
- #define bec tra s && and #,0x08 && xor #,0x08 && bnz
- #define bne bec
- #define blc tra s && and #,0x04 && xor #,0x04 && bnz
- #define bzc tra s && and #,0x02 && xor #,0x02 && bnz
- #define bcc tra s && and #,0x01 && xor #,0x01 && bnz
- ;multiple flag branches
- #define bgtu tra s && and #,0b1100 && bzs
- ;ina
- #define ini ina i
- #define inl ina l
- #define inh ina h
- #define inc ina c
- ;tar
- #define tai tar i
- #define tal tar l
- #define tah tar h
- #define tas tar s
- ;tra
- #define tia tra i
- #define tla tra l
- #define tha tra h
- #define tsa tra s
- ;ldr
- #define ldi ldr i
- #define ldi_abs ldi #,0 && ldi @,
- #define ldl ldr l
- #define ldh ldr h
- #define lda ldr a
- #define lda_abs_s(_n) \
- sti $,_SCRATCH_A && ldi #,0 &&\
- lda @,_n && ldi @,_SCRATCH_A
- ;str
- #define sti str i
- #define stl str l
- #define sth str h
- #define sta str a
- ;ror
- #define rol(_d,_n) ror _d,8-_n
- #define shl(_d,_n) ror _d,8-_n && and #,0xff<<_n
- #define shr(_d,_n) ror _d,_n && and #,0xff>>_n
- ;ora
- #define ora_abs(_n) \
- sti $,_SCRATCH_A && ldi #,0 &&\
- ora @,_n && ldi @,_SCRATCH_A
- ;sys
- #define wait_frame sys #,0x00
- #define wait_frames(_d,_n) lda _d,_n && sys #,0x01
- #define set_canvas(_d,_c) lda _d,_c && sys #,0x02
- #define rand sys #,0xfe
- #define get_key(_d,_k) lda _d,_k && sys #,0xff
- #define ldc_imm(_v16) ldl #,_l(_v16) && ldh #,_h(_v16)
- ;multi byte compare and branch (replace _skip with raw offset)
- #define bcltu_imm(_v16, _dst, _skip) \
- tha && cmp #,_h(_v16) &&\
- blt _dst && bgtu _skip &&\
- tla && cmp #,_l(_v16) &&\
- blt _dst
- #define bceq_imm(_v16, _dst, _skip) \
- tha && cmp #,_h(_v16) &&\
- bne _skip &&\
- tla && cmp #,_l(_v16) &&\
- beq _dst
- #define bcne_imm(_v16, _dst) \
- tha && cmp #,_h(_v16) && bne _dst &&\
- tla && cmp #,_l(_v16) && bne _dst
- #define bcnz_imm(_dst) \
- tha && bnz _dst &&\
- tla && bnz _dst
- ;\pseudoOps.asm
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement