Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

color cycling, not too happy with it

  • Loading branch information...
commit a087cd94fc9b807586612cb25baf3cf6aba4b498 1 parent 3039702
@hcs64 authored
Showing with 113 additions and 11 deletions.
  1. +6 −0 mem.as
  2. +4 −4 newdlist.as
  3. +103 −7 test.as
View
6 mem.as
@@ -68,6 +68,12 @@ byte line_err1, pad1e
byte head_poly, pad1f
byte tail_poly, pad20
+byte pal_cur, pad21
+byte pal_dest, pad22
+byte pal_delay, pad23
+byte pal_timer, pad24
+byte rndx, pad25
+byte rndy, pad26
#ram.end
View
8 newdlist.as
@@ -1,6 +1,6 @@
// threaded display list generation
-#define MAX_VBLANK_CYCLES 2150
+#define MAX_VBLANK_CYCLES 2080
// 54 cycles
// 41 bytes
@@ -112,7 +112,7 @@ dlist_end_common:
function process_dlist()
{
- // 28 cycles into vblank already
+ // 100 cycles into vblank already
// disable rendering
@@ -140,11 +140,11 @@ function process_dlist()
// approx 2270 cycles per vblank
// -
- // pre-dlist: 84
+ // pre-dlist: 156
// possible wrap: 10
// time to reenable rendering: 19
// --------------
- // cycles left for dlist: 2157
+ // cycles left for dlist: 2085
}
function finalize_dlist()
View
110 test.as
@@ -39,6 +39,11 @@ interrupt.nmi int_nmi()
lda #1 // 2
sta nmi_hit // 3
+ sty rndy // 3
+ stx rndx // 3
+ ldy pal_cur
+ set_palette() // 6 + 60
+
process_dlist() // 6+
pla
@@ -136,6 +141,13 @@ function mystify_test()
sta head_poly
sta tail_poly
+ lda #$21
+ sta pal_cur
+ lda #$0
+ sta pal_timer
+ lda #$5
+ sta pal_delay
+
// draw initial polygons
draw_poly()
draw_poly()
@@ -144,16 +156,98 @@ function mystify_test()
finish_frame()
- //lda #0
- //sta highest_frame_time
-
forever {
clear_poly()
draw_poly()
+
+ change_palette()
finish_frame()
}
}
+function change_palette()
+{
+ dec pal_timer
+ bmi time_to_go
+ rts
+time_to_go:
+
+ lda pal_delay
+ sta pal_timer
+
+ lda pal_dest
+ cmp pal_cur
+ if (equal)
+ {
+ lda rndx
+ and #$3F
+ sta pal_dest
+
+ and #$F
+ cmp #$C
+ if (not minus)
+ {
+ lda pal_dest
+ and #$37
+ sta pal_dest
+ }
+
+ lda pal_dest
+ and #$30
+ if (zero)
+ {
+ lda pal_dest
+ ora #$10
+ sta pal_dest
+ }
+
+ lda rndy
+ and #3
+ clc
+ adc #5
+ sta pal_delay
+ }
+
+ lda pal_dest
+ and #$F
+ sta tmp_byte
+
+ lda pal_cur
+ and #$F
+ cmp tmp_byte
+ beq pal_hue_done
+ bpl pal_hue_pl
+ inc pal_cur
+ bne pal_change_end
+pal_hue_pl:
+ dec pal_cur
+ jmp pal_change_end
+
+pal_hue_done:
+
+ lda pal_dest
+ and #$30
+ sta tmp_byte
+
+ lda pal_cur
+ and #$30
+ cmp tmp_byte
+ beq pal_change_end
+ bpl pal_value_pl
+ clc
+ lda pal_cur
+ adc #$10
+ sta pal_cur
+ bne pal_change_end
+pal_value_pl:
+ sec
+ lda pal_cur
+ sbc #$10
+ sta pal_cur
+
+pal_change_end:
+}
+
function draw_poly()
{
ldx head_poly
@@ -331,12 +425,15 @@ function clear_vram()
function init_vram()
{
- init_palette()
+ ldy #$21
+ set_palette()
init_attrs()
init_names()
}
-function init_palette()
+// Y = fg color
+// 60 cycles w/ rts
+function set_palette()
{
// Setup palette
lda #hi(PAL_0_ADDRESS)
@@ -345,8 +442,7 @@ function init_palette()
sta PPU.ADDRESS
// palette 0
- ldx #0x0F // bg
- ldy #0x20 // fg
+ ldx #0x0f // bg
stx PPU.IO // 00: bg
sty PPU.IO // 01: fg
stx PPU.IO // 10: bg
Please sign in to comment.
Something went wrong with that request. Please try again.