Add a simple boot rom stub
so we can start the emulated console without need for special case in the code, and not adding any copyrighted material in the project. Also automatically copy the stub rom in the build folder.
This commit is contained in:
parent
e28317d29e
commit
432844304e
@ -36,6 +36,13 @@ set_property(TARGET wonderswan PROPERTY CXX_STANDARD 98)
|
||||
target_compile_definitions(wonderswan PUBLIC VERSION="${VERSION}")
|
||||
target_include_directories(wonderswan PUBLIC source)
|
||||
|
||||
add_custom_command(
|
||||
TARGET wonderswan POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_SOURCE_DIR}/irom_stub/*.bin
|
||||
${CMAKE_CURRENT_BINARY_DIR}/
|
||||
)
|
||||
|
||||
add_subdirectory(source)
|
||||
|
||||
target_link_libraries(wonderswan wswan glfw ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY})
|
||||
|
||||
20
irom_stub/Makefile
Normal file
20
irom_stub/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
.PHONY: all clean
|
||||
|
||||
all: ws_irom.bin wsc_irom.bin wc_irom.bin
|
||||
|
||||
clean:
|
||||
@echo " RM"
|
||||
@rm -f *.bin
|
||||
|
||||
ws_irom.bin: irom_stub.asm
|
||||
@echo " AS $@"
|
||||
@nasm $^ -o $@ -DWONDERSWAN=1
|
||||
|
||||
wsc_irom.bin: irom_stub.asm
|
||||
@echo " AS $@"
|
||||
@nasm $^ -o $@ -DWONDERSWANCOLOR=1
|
||||
|
||||
wc_irom.bin: irom_stub.asm
|
||||
@echo " AS $@"
|
||||
@nasm $^ -o $@ -DSWANCRYSTAL=1
|
||||
|
||||
104
irom_stub/irom_stub.asm
Normal file
104
irom_stub/irom_stub.asm
Normal file
@ -0,0 +1,104 @@
|
||||
; WonderSwan Internal ROM Stub
|
||||
; --------------------------------------
|
||||
; Version 1.0
|
||||
|
||||
; This is a replacement for the internal rom to prevent using/including any copyrighted material.
|
||||
; It does nothing, just lauching the cartridge.
|
||||
; It may later include a bootsplah.
|
||||
|
||||
%ifdef WONDERSWAN
|
||||
%define ROM_SIZE 4096
|
||||
%define ROM_SEG 0FF00h
|
||||
%else
|
||||
%define ROM_SIZE 8192
|
||||
%define ROM_SEG 0FE00h
|
||||
%endif
|
||||
|
||||
; Setup NASM for a 80186
|
||||
bits 16
|
||||
cpu 186
|
||||
|
||||
org 0000h
|
||||
|
||||
%define JUMPER_LOCATION 0000h:0400h
|
||||
; ---------------------------------------------------------------------------------------------
|
||||
; Boot ROM jumper
|
||||
; ---------------------------------------------------------------------------------------------
|
||||
; Lock the bootrom
|
||||
; Clear a bit of itself
|
||||
; Jump to FFFF:FFF0
|
||||
;
|
||||
; Must be copied to 0000:0400 then jmp 0000:0400
|
||||
ram_jumper:
|
||||
|
||||
; Lock the boot rom away
|
||||
IN al, 0A0h
|
||||
OR al, 001h ; Bit 0 lock the boot rom
|
||||
out 0A0h, al
|
||||
|
||||
mov ax, cs
|
||||
mov es, ax
|
||||
mov di, 0400h
|
||||
mov cx, (.rm_te_end - ram_jumper)
|
||||
xor ax, ax
|
||||
xor bx, bx
|
||||
.rm_te_end:
|
||||
rep stosb
|
||||
jmp 0FFFFh:00000h
|
||||
ram_jumper_end:
|
||||
|
||||
_start:
|
||||
cli
|
||||
cld
|
||||
push cs
|
||||
pop ds
|
||||
xor ax, ax
|
||||
mov es, ax
|
||||
|
||||
; Clear the IRAM
|
||||
mov di, 0
|
||||
mov cx, 16384
|
||||
xor al, al
|
||||
rep stosb ; STOSB -> ES:DI
|
||||
|
||||
; Copy the jumper
|
||||
mov si, ram_jumper
|
||||
mov cx, (ram_jumper_end - ram_jumper)
|
||||
mov di, 0400h
|
||||
xor ax, ax
|
||||
mov es, ax
|
||||
rep movsb ; DS:SI -> ES:DI
|
||||
|
||||
; Do some register cleanup
|
||||
mov al, 0FFh
|
||||
out 0C0h, al
|
||||
out 0C1h, al
|
||||
out 0C2h, al
|
||||
xor ax, ax
|
||||
xor cx, cx
|
||||
xor dx, dx
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
|
||||
; Jump to the jumper!
|
||||
jmp JUMPER_LOCATION
|
||||
|
||||
%ifdef WONDERSWAN
|
||||
db "WonderSwan"
|
||||
%elifdef WONDERSWANCOLOR
|
||||
db "WonderSwan Color"
|
||||
%elifdef SWANCRYSTAL
|
||||
db "WonderSwan Crystal"
|
||||
%else
|
||||
%endif
|
||||
db " internal ROM Stub for NewOswan (c)2021 986-Studio"
|
||||
; Create at the end of the block, add padding if needed
|
||||
TIMES (ROM_SIZE - 16) - ($-$$) DB 0FFh
|
||||
|
||||
jmp ROM_SEG:_start ; 0
|
||||
db 00 ; ?? ; 5
|
||||
db 0F0h ; Dev ID ; 6
|
||||
db 00 ; Min Swan type ; 7
|
||||
db 00000100b ; flags ; C
|
||||
db 01 ; No RTC ; D
|
||||
dw 0FFFFh ; CRC (need to update it after, but as not used by the rom, no need for now)
|
||||
BIN
irom_stub/wc_irom.bin
Normal file
BIN
irom_stub/wc_irom.bin
Normal file
Binary file not shown.
BIN
irom_stub/ws_irom.bin
Normal file
BIN
irom_stub/ws_irom.bin
Normal file
Binary file not shown.
BIN
irom_stub/wsc_irom.bin
Normal file
BIN
irom_stub/wsc_irom.bin
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user