Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef _STD_PSEUDOOPS_H
- #define _STD_PSEUDOOPS_H
- ;std/pseudoOps.h
- #define _SCRATCH_A 0xf0
- #define _SCRATCH_B 0xf1
- #define _SCRATCH_C 0xf2
- #define _SCRATCH_D 0xf3
- ;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
- #define rts jpr
- ;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
- #define bgts tra s && and #,0b11000 && bzs
- ;long branches
- #define bns_long bnc @+3 jpa
- #define bos_long boc @+3 jpa
- #define bds_long bdc @+3 jpa
- #define bLs_long bLc @+3 jpa
- #define bes_long bec @+3 jpa
- #define bls_long blc @+3 jpa
- #define bzs_long bzc @+3 jpa
- #define bcs_long bcc @+3 jpa
- ;
- #define bnc_long bns @+3 jpa
- #define boc_long bos @+3 jpa
- #define bdc_long bds @+3 jpa
- #define bLc_long bLs @+3 jpa
- #define bec_long bes @+3 jpa
- #define blc_long bls @+3 jpa
- #define bzc_long bzs @+3 jpa
- #define bcc_long bcs @+3 jpa
- ;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
- #define ldc_imm(_v16) ldl #,_l(_v16) && ldh #,_h(_v16)
- #define ldc_abs(_addr) \
- sti $,_SCRATCH_A && ldi #,0 &&\
- ldl @,_addr && ldh @,1+_addr &&\
- ldi @,_SCRATCH_A
- ;str
- #define sti str i
- #define stl str l
- #define sth str h
- #define sta str a
- #define stc_abs(_addr) stl $,(_addr) && sth $,1+(_addr)
- ;ror
- #define rol(_d,_n) ror _d,8-(_n)
- #define shl(_d,_n) ror _d,8-(_n) && and #,_l(0xff<<(_n))
- #define shr(_d,_n) ror _d,(_n) && and #,_l(0xff>>(_n))
- ;and
- ;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 get_key_nc(_d,_k) \
- lda _d,_k &&\
- stc_abs(_SCRATCH_B) &&\
- sys #,0xff &&\
- lda_abs_s(_SCRATCH_B)
- ;multi byte compare and branch
- #define bcltu_imm(_v16, _dst) \
- tha && cmp #,_h(_v16) &&\
- blt _dst && bgtu @+5 &&\
- tla && cmp #,_l(_v16) &&\
- blt _dst
- #define bceq_imm(_v16, _dst) \
- tha && cmp #,_h(_v16) &&\
- bne @+5 &&\
- 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
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement