Verified Commit 912b1e44 authored by molive's avatar molive 🤠
Browse files

Finished for now

parent f39be75b
*.sym
*.sfc
.build
.build_libsfx
\ No newline at end of file
.build_libsfx
*.bp
\ No newline at end of file
# Name
name := Template
name := scchallengespiro
debug := 0
export LIBSFX_RUNCMD = cmd.exe -c "start $(realpath $(rom))"
......
# scchallengespiro
A spirograph on the SNES
Written as part of the Southampton Space Cadets.
Requires LibSFX to build
\ No newline at end of file
.include "libSFX.i"
Main:
;libSFX calls Main after CPU/PPU registers, memory and interrupt handlers are initialized.
;Set color 0
CGRAM_setcolor_rgb 0, 7,31,31
;Turn on screen
;The vblank interrupt handler will copy the value in SFX_inidisp to INIDISP ($2100)
lda #inidisp(ON, DISP_BRIGHTNESS_MAX)
sta SFX_inidisp
;Turn on vblank interrupt
VBL_on
: wai
bra :-
import math
for i in range(0,256):
n = int(math.sin(i/256*math.tau)*65535/2)
if n < 0:
n += 65536
print(".word $"+hex(n)[2:])
\ No newline at end of file
.include "libSFX.i"
.struct circleStatic
radius .byte ;1.7 signed fixed
speed .word ;8.8 fixed
.endstruct
.struct circleVar
rotation .word ;8.8 fixed
padding .byte
.endstruct
screen = $0000
map = $8000
Main:
break
RW a16i8
ldx #0 ;work out how many circles there is
: inx
lda circledata, x
bne :-
stx z:nocircles
WRAM_memset screenbuf, screenbuflen, 0 ;clear the screen
; ldx z:nocircles ;clear variables
;: stz z:circles, x
; dex
; bpl :-
CGRAM_setcolor_rgb 0, 31,31,31
CGRAM_setcolor_rgb 1, 0,0,31
RW a8i16 ;make the map
lda #$80
sta VMAINC
stz VMADDL
lsr
sta VMADDH
RW a16
lda #0
: sta VMDATAL
inc
cmp #$3FF
bne :-
RW a8
lda #bgmode(0,0,BG_SIZE_8X8,BG_SIZE_8X8,BG_SIZE_8X8,BG_SIZE_8X8)
sta BGMODE
lda #bgsc(map,SC_SIZE_32X32)
sta BG1SC
lda #bg12nba(screen,0)
sta BG12NBA
lda #tm(1,0,0,0,0)
sta TM
lda #inidisp(ON, DISP_BRIGHTNESS_MAX)
sta SFX_inidisp
VBL_set vblank
VBL_on
: jsr getPos
jsr plotPixel
;wai
bra :-
.proc plotPixel
RW_forced a8i16
lda z:posy+1 ;load the x and y into an address format
add #128
xba
lda z:posx+1
RW a16
add #128
;cmp #0
;and #%0001111111111111
lsr ;divide by 8
lsr
lsr
tax
lda z:posx+1 ;get index into byte
and #%00000111
tay
lda #0 ;set the correct bit in A
sec
: ror
dey
bpl :-
ora f:screenbuf, x ;merge A with background
sta f:screenbuf, x
rts
.endproc
.proc getPos
RW_forced a16i16
ldx #0
stz posx
stz posy
RW_assume i8
loop:
lda #0
RW a8i16
lda z:circles+1, x ;load rot into A then Y
RW a16
asl
tay
phy
lda sin, y ;Perform rot.sin()
RW a8
sta $211B ;Store sin into multiplier
xba
sta $211B
stz $211C
RW i8
ldy circledata, x ;load radius into y
sty $211C ;Store radius into multiplier
lda $2134 ;Load upper 16bit of 24bit output
rol
RW a16
lda $2135
rol
add z:posx ;add it to the x
sta z:posx
RW i16
ply ;load rot into Y
lda cos, y ;Perform rot.cos()
RW a8
sta $211B ;Store sin into multiplier
xba
sta $211B
lda $2134 ;Load upper 16bit of 24bit output
rol
RW a16
lda $2135
rol
add z:posy ;add it to the y
sta z:posy
lda circledata+1, x ;rot += speed
add z:circles, x
sta z:circles, x
RW i8
inx
inx
inx
cpx nocircles
bmi loop
rts
.endproc
.proc vblank
VRAM_memcpy screen, screenbuf, screenbuflen, 4, 0, $18 ;copy the screen over
rtl
.endproc
.zeropage
posx: .res 2 ;signed 1+7.8 position
posy: .res 2
nocircles: .res 1 ;number of circles * 3
circles: .res 192 ;64 circles max
.segment "HIRAM"
screenbuflen = (256*239)/8
screenbuf: .res screenbuflen
.rodata
.include "sin.i"
circledata: ;MAX 192 bytes
.byte %01000000 ;0.5
.word %0000000000000101 ;0.02
.byte %00100000 ;0.25
.word %0000000000000111 ;0.03
.byte %00001100 ;0.1
.word %0000000000000101 ;0.02
.byte %00001101 ;0.2
.word %0000000000011001 ;0.1
.word 0
sin:
.word $0
.word $324
.word $647
.word $96a
.word $c8b
.word $fab
.word $12c7
.word $15e1
.word $18f8
.word $1c0b
.word $1f19
.word $2223
.word $2527
.word $2826
.word $2b1f
.word $2e10
.word $30fb
.word $33de
.word $36b9
.word $398c
.word $3c56
.word $3f17
.word $41cd
.word $447a
.word $471c
.word $49b3
.word $4c3f
.word $4ebf
.word $5133
.word $539a
.word $55f5
.word $5842
.word $5a82
.word $5cb3
.word $5ed7
.word $60eb
.word $62f1
.word $64e8
.word $66cf
.word $68a6
.word $6a6d
.word $6c23
.word $6dc9
.word $6f5e
.word $70e2
.word $7254
.word $73b5
.word $7504
.word $7641
.word $776b
.word $7884
.word $7989
.word $7a7c
.word $7b5c
.word $7c29
.word $7ce3
.word $7d89
.word $7e1d
.word $7e9c
.word $7f09
.word $7f61
.word $7fa6
.word $7fd8
.word $7ff5
cos:
.word $7fff
.word $7ff5
.word $7fd8
.word $7fa6
.word $7f61
.word $7f09
.word $7e9c
.word $7e1d
.word $7d89
.word $7ce3
.word $7c29
.word $7b5c
.word $7a7c
.word $7989
.word $7884
.word $776b
.word $7641
.word $7504
.word $73b5
.word $7254
.word $70e2
.word $6f5e
.word $6dc9
.word $6c23
.word $6a6d
.word $68a6
.word $66cf
.word $64e8
.word $62f1
.word $60eb
.word $5ed7
.word $5cb3
.word $5a82
.word $5842
.word $55f5
.word $539a
.word $5133
.word $4ebf
.word $4c3f
.word $49b3
.word $471c
.word $447a
.word $41cd
.word $3f17
.word $3c56
.word $398c
.word $36b9
.word $33de
.word $30fb
.word $2e10
.word $2b1f
.word $2826
.word $2527
.word $2223
.word $1f19
.word $1c0b
.word $18f8
.word $15e1
.word $12c7
.word $fab
.word $c8b
.word $96a
.word $647
.word $324
.word $0
.word $fcdc
.word $f9b9
.word $f696
.word $f375
.word $f055
.word $ed39
.word $ea1f
.word $e708
.word $e3f5
.word $e0e7
.word $dddd
.word $dad9
.word $d7da
.word $d4e1
.word $d1f0
.word $cf05
.word $cc22
.word $c947
.word $c674
.word $c3aa
.word $c0e9
.word $be33
.word $bb86
.word $b8e4
.word $b64d
.word $b3c1
.word $b141
.word $aecd
.word $ac66
.word $aa0b
.word $a7be
.word $a57e
.word $a34d
.word $a129
.word $9f15
.word $9d0f
.word $9b18
.word $9931
.word $975a
.word $9593
.word $93dd
.word $9237
.word $90a2
.word $8f1e
.word $8dac
.word $8c4b
.word $8afc
.word $89bf
.word $8895
.word $877c
.word $8677
.word $8584
.word $84a4
.word $83d7
.word $831d
.word $8277
.word $81e3
.word $8164
.word $80f7
.word $809f
.word $805a
.word $8028
.word $800b
.word $8001
.word $800b
.word $8028
.word $805a
.word $809f
.word $80f7
.word $8164
.word $81e3
.word $8277
.word $831d
.word $83d7
.word $84a4
.word $8584
.word $8677
.word $877c
.word $8895
.word $89bf
.word $8afc
.word $8c4b
.word $8dac
.word $8f1e
.word $90a2
.word $9237
.word $93dd
.word $9593
.word $975a
.word $9931
.word $9b18
.word $9d0f
.word $9f15
.word $a129
.word $a34d
.word $a57e
.word $a7be
.word $aa0b
.word $ac66
.word $aecd
.word $b141
.word $b3c1
.word $b64d
.word $b8e4
.word $bb86
.word $be33
.word $c0e9
.word $c3aa
.word $c674
.word $c947
.word $cc22
.word $cf05
.word $d1f0
.word $d4e1
.word $d7da
.word $dad9
.word $dddd
.word $e0e7
.word $e3f5
.word $e708
.word $ea1f
.word $ed39
.word $f055
.word $f375
.word $f696
.word $f9b9
.word $fcdc
.word $0
.word $324
.word $647
.word $96a
.word $c8b
.word $fab
.word $12c7
.word $15e1
.word $18f8
.word $1c0b
.word $1f19
.word $2223
.word $2527
.word $2826
.word $2b1f
.word $2e10
.word $30fb
.word $33de
.word $36b9
.word $398c
.word $3c56
.word $3f17
.word $41cd
.word $447a
.word $471c
.word $49b3
.word $4c3f
.word $4ebf
.word $5133
.word $539a
.word $55f5
.word $5842
.word $5a82
.word $5cb3
.word $5ed7
.word $60eb
.word $62f1
.word $64e8
.word $66cf
.word $68a6
.word $6a6d
.word $6c23
.word $6dc9
.word $6f5e
.word $70e2
.word $7254
.word $73b5
.word $7504
.word $7641
.word $776b
.word $7884
.word $7989
.word $7a7c
.word $7b5c
.word $7c29
.word $7ce3
.word $7d89
.word $7e1d
.word $7e9c
.word $7f09
.word $7f61
.word $7fa6
.word $7fd8
.word $7ff5
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment