Skip to content

Instantly share code, notes, and snippets.

@JimmyDansbo
Last active December 19, 2020 10:35
Show Gist options
  • Save JimmyDansbo/fd4f191e174ec002c4549607a8ba3e43 to your computer and use it in GitHub Desktop.
Save JimmyDansbo/fd4f191e174ec002c4549607a8ba3e43 to your computer and use it in GitHub Desktop.
Random number between 0 and 9
*=$0801
!word $080C ; Pointer to next BASIC line
!word $000A ; Line number $000A = 10
!byte $9E ; SYS BASIC token
!pet " $810",0 ; Address where ASM starts
!word $0000 ; EOF BASIC program
*=$0810
CHROUT = $FFD2
SEED = $9F64 ; VIA timer low-byte
main:
lda SEED
and #$0F ; 10 is max so use $0F to get down to 15
cmp #10
bcs main ; Try again if .A is >= 10
ora #$30 ; OR with $30 to get petscii character
jsr CHROUT ; Print character
lda #' ' ; Print a space
jsr CHROUT
jmp main
rts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment