Name | Stack effect | Operation | Operation after a b ? |
Operation after a 0? |
ASM |
---|---|---|---|---|---|
if |
( -- ) |
if zero flag = 0 | if a != b | if a | beq ... |
=if |
( -- ) |
if zero flag = 1 | if a == b | if !a | bne ... |
+if |
( -- ) |
if negative flag = 0 | if (i16)a - (i16)b >= 0 | if (i16)a >= 0 | bmi ... |
-if |
( -- ) |
if negative flag = 1 | if (i16)a - (i16)b < 0 | if (i16)a < 0 | bpl ... |
vif |
( -- ) |
if overflow flag = 0 | n/a | n/a | bvs ... |
^if |
( -- ) |
if overflow flag = 1 | n/a | n/a | bvc ... |
<if |
( -- ) |
if carry flag = 0 | if (u16)a < (u16)b | if false | bcs ... |
>if |
( -- ) |
if carry flag = 1 | if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 constant nil | |
: cons ( car cdr -- list ) here >r swap , , r> ; | |
: list ( x... #x -- list ) nil swap 0 ?do cons loop ; | |
: list: ( x... #x "name" -- ) list constant ; | |
: car ( list -- car ) @ ; | |
: car! ( car list -- ) ! ; | |
: cdr ( list -- cdr ) cell+ @ ; | |
: cdr! ( cdr list -- ) cell+ ! ; | |
: list. ( list -- ) begin ?dup while dup car . cdr repeat ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daiyon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reset: | |
; initialize everything... | |
main: | |
; update game state... | |
; process sprites in a copy of OAM stored in WRAM... | |
; other stuff... | |
inc ReadyFlag ; signal that we're done processing for this frame | |
spin: | |
lda ReadyFlag ; wait until flag is cleared by NMI routine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zero: | |
.db $00 | |
; assuming A is 8-bit, X/Y are 16-bit | |
clear_wram: | |
; From fixed CPU address to IO register, | |
; transfer unit is one byte | |
lda #%00001000 | |
sta DMAP0 ; $4300 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nfmt::Nfmt; | |
fn main() { | |
println!("{}", number(25252)); // 25,252 | |
println!("{}", number(-500)); // -500 | |
println!("{}", cents(1234567890)); // $12,345,678.90 | |
println!("{}", cents(-200000)); // ($2,000.00) | |
println!("{}", hex(32768)); // 0x8000 | |
println!("{}", hex(!0)); // 0xFFFFFFFFFFFFFFFF | |
println!("{}", yen(573765)); // 57万3765円 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#define NFMT_BUF_LEN 32 | |
const char nfmt_set[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
char nfmt_base; | |
char nfmt_buf[NFMT_BUF_LEN+1] = {0}; | |
char* nfmt_ptr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub struct SingleCursor { | |
cursor: u16, | |
mask: u16 | |
} | |
impl SingleCursor { | |
pub fn new(offset: u16, mask: u16) -> SingleCursor { | |
SingleCursor { | |
cursor: offset, | |
mask: mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut ram = [0u16; 0x2000]; | |
let mut rom = [0xffffu16; 0xc000]; | |
{ | |
let mut ptr = 0x0000; | |
let mut mov = |dst, src| { | |
rom[ptr+0] = src; | |
rom[ptr+1] = dst; | |
ptr += 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Goal: to turn controller button samples, incoming on the x register each | |
; frame, into three variables: | |
; - cur, which represents the current state of the controller buttons | |
; - prs, which represents the buttons pressed this frame | |
; - rls, which represents the buttons released this frame | |
; | |
; Example: | |
; x cur prs rls | |
; ................ ................ ................ <- initial values | |
; ...........1.... ...........1.... ...........1.... ................ |
NewerOlder