Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme Loading #240

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ verilog/*/incremental_db
obj/
snes/menu.rtc
snes/menu.srm
!www/**/*
www/themes/Themes/**/*
62 changes: 47 additions & 15 deletions snes/const.a65
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,59 @@ hdma_bg2scroll_src
.byt 0

; colors:
; upper border: + #547fff -> 10,15,31
; selection bar:+ #5400ff -> 10,0,31
; lower border: 1/2 #5400ff
; upper border: add #547fff -> 10,15,31
; selection bar: add #5400ff -> 10,0,31
; lower border: avg #5400ff
; COLDATA can only set one distinct value to any set of components (R/G/B)
; per write so setting up the initial color takes three entries.
hdma_math_src
.byt 1 ; these are filled in...
.byt $00, $2a
.byt $00, $00
.byt 1 ; ...to move the color bar
.byt $00, $4f
.byt 1
.byt $33, $9f
.byt 7
.byt $33, $40
.byt 1
.byt $73, $00
.byt 1
.byt $00, $e0
.byt $00, $00
.byt $8c
.byt $00, $00 ; placeholders
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; |
.byt $00, $00 ; to be filled in by color tables below
.byt $00, $e0 ; set RGB; value = $00; also disable math
.byt 0

hdma_bar_color_src
.byt $2a, $4f, $9f, $40 ; normal color
.byt $36, $4f, $8a, $40 ; highlight color (active editing)
; normal color
.byt $00, $2a ; set R; value = $0a
.byt $00, $4f ; set G; value = $0f
.byt $33, $9f ; set B; value = $1f; also enable math
.byt $33, $40 ; set G; value = $00
.byt $33, $00 ; math stays on, no color changes
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $73, $00 ; change math to averaging mode for bottom edge of bar
.byt $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff; padding to 32b align tables

; highlight color (active editing)
.byt $00, $36 ; set R; value = $16
.byt $00, $4f ; set G; value = $0f
.byt $33, $8a ; set B; value = $0a
.byt $33, $40 ; set G; value = $00
.byt $33, $00 ; math stays on, no color changes
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $33, $00 ; |
.byt $73, $00 ; change math to averaging mode for bottom edge of bar
.byt $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff; padding to 32b align tables

oam_data_l
.byt 88, 56, 0, $08
Expand Down
15 changes: 8 additions & 7 deletions snes/data.a65
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ bar_x .byt 0 ; pixel x position of select bar
bar_y .byt 0 ; pixel y position of select bar
bar_w .byt 0 ; bar width
bar_wl .byt 0 ; bar width
bar_color .word 0 ; bar color index (lookup into HDMA table presets)
filesel_state .byt 0 ; menu state (0=file select)
filesel_dirty .byt 0 ; menu dirty (e.g. after state change or when redraw is needed)
filesel_sel .word 0 ; selected item #
Expand Down Expand Up @@ -154,18 +155,18 @@ hdma_math
.byt 0,0
.byt 0
.byt 0,0
hdma_math_upperborder
.byt 0
.byt 0,0
hdma_math_selection
.byt 0
.byt 0,0
hdma_math_lowerborder
.byt 0
.byt 0,0
.byt 0
.byt 0,0
.byt 0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0,0
.byt 0

Expand Down
6 changes: 5 additions & 1 deletion snes/main.a65
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,15 @@ setup_gfx:
ldx #!hdma_math
stx $2181
sta $2183
DMA7(#$00, #19, #^hdma_math_src, #!hdma_math_src, #$80);
DMA7(#$00, #32, #^hdma_math_src, #!hdma_math_src, #$80);

; initialize window stack
ldx #$ffff
stx window_stack_head

; initialize bar color
lda #$00
jsr set_bar_color
rts

genfonts:
Expand Down
5 changes: 3 additions & 2 deletions snes/memmap.i65
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
#define WRAM_WAIT_MCU $7EF200
#define WRAM_LOAD_ULTRA16_CFG $7EF210

#define ROOT_DIR $C10000
#define THEME_BASE $C10000
#define ROOT_DIR $C20000

#define NUM_CHEATS $CFFFFE
#define CHEAT_ADDR $D00000
Expand Down Expand Up @@ -171,6 +172,6 @@
#define TYPE_SPC $03
#define TYPE_IPS $04
#define TYPE_CHT $05
#define TYPE_SKIN $06
#define TYPE_THM $06
#define TYPE_SUBDIR $40
#define TYPE_PARENT $80
2 changes: 2 additions & 0 deletions snes/menu.a65
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,10 @@ menu_edit_value:
txy ; save address of menu entry (bank is still set)
tax ; jump table offset
phx
phy
lda #$01
jsr set_bar_color
ply
plx
rep #$20 : .al
lda [w_value_addr]
Expand Down
3 changes: 2 additions & 1 deletion snes/reset.a65
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ NMI_ROUTINE:
stx $2116
DMA7(#$01, #64*9, #^BG2_TILE_BUF, #!BG2_TILE_BUF, #$18)
+
lda bar_yl
lda bar_yl ; calculate (Y-1) * 8 - 2
dec
asl
asl
dec
asl
sta bar_y ; physical pos = logical pos * 8 - 8
cmp #224
Expand Down
21 changes: 12 additions & 9 deletions snes/ui.a65
Original file line number Diff line number Diff line change
Expand Up @@ -683,18 +683,21 @@ right_align:
; a: bar "palette" number
set_bar_color:
php
sep #$30 : .as : .xs
rep #$31 : .al : .xl ; + clear carry
and #$00ff
asl
asl
asl
asl
asl
adc #!hdma_bar_color_src
tax
lda @hdma_bar_color_src, x
sta @hdma_math+2
lda @hdma_bar_color_src+1, x
sta @hdma_math+5
lda @hdma_bar_color_src+2, x
sta @hdma_math+8
lda @hdma_bar_color_src+3, x
sta @hdma_math+11
ldy #!hdma_math+7
lda #$16-1
phb
; MVN/MVP order is reversed in snescom? (compared with official docs)
mvn ^hdma_math, ^hdma_bar_color_src
plb
plp
rts

Expand Down
2 changes: 1 addition & 1 deletion src/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cfg_t CFG_DEFAULT = {
.sort_directories = 1,
.hide_extensions = 0,
.cx4_speed = 0,
.skin_name = "sd2snes.skin",
.theme_name = "sd2snes.thm",
.control_type = 0,
.msu_volume_boost = 0,
.onechip_transient_fixes = 0,
Expand Down
2 changes: 1 addition & 1 deletion src/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ typedef struct __attribute__ ((__packed__)) _cfg_block {
uint8_t sort_directories; /* sort directories (slower) (default: on) */
uint8_t hide_extensions; /* hide file extensions (default: off) */
uint8_t cx4_speed; /* Cx4 speed (0: original, 1: no waitstates */
uint8_t skin_name[128]; /* file name of selected skin */
uint8_t theme_name[128]; /* file name of selected theme */
uint8_t control_type; /* control type (0: A=OK, B=Cancel; 1: A=Cancel, B=OK) */
uint8_t msu_volume_boost; /* volume boost (0: none; 1=+3.5dB; 2=+6dB; 3=+9dB; 4=+12dB) */
uint8_t onechip_transient_fixes; /* override register 2100 bits 3-0 */
Expand Down
4 changes: 2 additions & 2 deletions src/filetypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ SNES_FTYPE determine_filetype(FILINFO fno) {
if(!strcasecmp(ext+1, "CHT")) {
return TYPE_CHT;
}
if(!strcasecmp(ext+1, "SKIN")) {
return TYPE_SKIN;
if(!strcasecmp(ext+1, "THM")) {
return TYPE_THM;
}
return TYPE_UNKNOWN;
}
Expand Down
2 changes: 1 addition & 1 deletion src/filetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef enum {
TYPE_SPC = 3,
TYPE_IPS = 4,
TYPE_CHT = 5,
TYPE_SKIN = 6,
TYPE_THM = 6,
TYPE_SUBDIR = 64,
TYPE_PARENT = 128
} SNES_FTYPE;
Expand Down
3 changes: 2 additions & 1 deletion src/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ extern char current_filename[];
#define SRAM_SAVE_ADDR (0xE00000L)

#define SRAM_MENU_ADDR (0xC00000L)
#define SRAM_DIR_ADDR (0xC10000L)
#define SRAM_THEME_ADDR (0xC10000L)
#define SRAM_DIR_ADDR (0xC20000L)
#define SRAM_DB_ADDR (0xC80000L)

#define SRAM_NUM_CHEATS (0xCFFFFEL)
Expand Down
3 changes: 3 additions & 0 deletions utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ rle: rle.o
genbsxpage: genbsxpage.o
$(CC) $(CFLAGS) $^ --output $@

palconv: palconv.o
$(CC) $(CFLAGS) $^ --output $@

%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@

Expand Down
Loading