Created
September 22, 2015 20:29
-
-
Save AfBu/cf52ed9dae866a04b1a8 to your computer and use it in GitHub Desktop.
Hello PICO-8 (Simple chip-8 program demo)
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
OPTION CHIP8 | |
JP LOOP ; jump to main loop | |
DA '[Hello PICO-8 by AfBu]' | |
LOOP: | |
RND V0,29 ; random value to register V0 (x) | |
RND V1,23 ; random value to register V1 (y) | |
ADD V1,4 ; add 4 to register V1 | |
CLS ; clear screen | |
CALL DRAW_PICO ; call drawing sub-routine | |
CALL DELAY ; call delay sub-routine | |
JP LOOP ; jump back to start of the loop | |
DRAW_PICO: | |
; P | |
LD I,PICO_P ; load P sprite adress into 16bit register | |
DRW V0,V1,5 ; draw sprite at V0,V1 with height of 5 pixels | |
; I | |
ADD V0,#6 ; add 6 to X position | |
LD I,PICO_I ; repeat all steps for netx letters | |
DRW V0,V1,5 | |
; C | |
ADD V0,#5 | |
LD I,PICO_C | |
DRW V0,V1,5 | |
; O | |
ADD V0,#5 | |
LD I,PICO_O | |
DRW V0,V1,5 | |
; - | |
ADD V0,#6 | |
LD I,PICO_D | |
DRW V0,V1,5 | |
; 8 | |
ADD V0,#3 | |
LD I,PICO_8 | |
DRW V0,V1,5 | |
; * | |
ADD V0,#5 | |
ADD V1,#FC | |
LD I,PICO_S | |
DRW V0,V1,5 | |
RET ; return from sub-routine | |
DELAY: | |
LD VF,60 ; load V15 register with time to wait (60 = 1 second) | |
LD DT,VF ; load V15 register to delay timer | |
MIDDELAY: | |
LD VF,DT ; load delay timer into V15 register | |
SNE VF,#00 ; skip next instruction if V15 does not equal zero | |
RET ; return from sub-routine | |
JP MIDDELAY ; jump to delay check | |
; define sprited for pico-8 logo | |
PICO_P: | |
DB $01111000,$11011000,$11111000,$11000000,$11000000 | |
PICO_I: | |
DB $11110000,$01100000,$01100000,$01100000,$11110000 | |
PICO_C: | |
DB $01110000,$11000000,$11000000,$11000000,$11110000 | |
PICO_O: | |
DB $01111000,$11011000,$11011000,$11011000,$11110000 | |
PICO_D: | |
DB #00,#00,$11000000,#00,#00 | |
PICO_8: | |
DB $01111000,$01001000,$11111000,$11001000,$11111000 | |
PICO_S: | |
DB $00100000,$01110000,$11111000,$01110000,$00100000 | |
; procedure to halt program by infinite loop | |
HALT: | |
JP HALT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment