abstract width, height, and depth

This commit is contained in:
Connor Olding 2018-08-24 05:09:34 +02:00
parent d5bfc3482f
commit 48939bb3d4
2 changed files with 39 additions and 6 deletions

View File

@ -1,6 +1,10 @@
// write some F3DZEX instructions to a0
// clobbers t0,t1,a0
constant WIDTH(320)
constant HEIGHT(240)
constant HICOLOR(0)
define dpos(0)
macro WriteDL(evaluate L, evaluate R) {
@ -31,6 +35,7 @@ if {dpos} >= 0x8000 {
// G_AD_DISABLE | G_CD_MAGICSQ | G_TC_FILT | G_TF_BILERP |
// G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_MDSFT_TEXTPERSP |
// G_CYC_FILL | G_PM_NPRIMITIVE
// TODO: try running without this
WriteDL(0xEF382C30, 0x00000000)
// G_GEOMETRYMODE
@ -38,7 +43,7 @@ if {dpos} >= 0x8000 {
WriteDL(0xD9000000, 0x00220405)
// G_SETSCISSOR coordinate order: (top, left), (right, bottom)
WriteDL(0xED000000 | (0 << 14) | (0 << 2), (640 << 14) | (480 << 2))
WriteDL(0xED000000 | (0 << 14) | (0 << 2), (WIDTH << 14) | (HEIGHT << 2))
// G_SETBLENDCOLOR
// sets alpha component to 8, everything else to 0
@ -54,14 +59,38 @@ if {dpos} >= 0x8000 {
// G_MOVEWORD, sets G_MW_CLIP+$001C
WriteDL(0xDB04001C, 0x10000 - 2)
// G_SETCIMG, set our color buffer (fmt 0, bit size %11, width)
WriteDL(0xFF180000 | (640 - 1), VIDEO_C_BUFFER)
// G_SETZIMG, set our z buffer
WriteDL(0xFE000000, VIDEO_Z_BUFFER)
// G_SETCIMG, set our z buffer as a color buffer so we can wipe it
WriteDL(0xFF100000 | (WIDTH - 1), VIDEO_Z_BUFFER)
WriteDL(0xE3000A01, 0x00300000) // G_SETOTHERMODE_H
WriteDL(0xE200001C, 0x00000000) // G_SETOTHERMODE_L
WriteDL(0xF7000000, 0xFFFCFFFC) // G_SETFILLCOLOR to default z value
// G_FILLRECT the whole z buffer
WriteDL(0xF6000000 | ((WIDTH - 1) << 14) | ((HEIGHT - 1) << 2), 0)
WriteDL(0xE7000000, 0) // G_RDPPIPESYNC
// G_SETCIMG, set our color buffer
if HICOLOR {
WriteDL(0xFF180000 | (WIDTH - 1), VIDEO_C_BUFFER)
} else {
WriteDL(0xFF100000 | (WIDTH - 1), VIDEO_C_BUFFER)
}
WriteDL(0xF8000000, 0x0A0A0A00) // G_SETFOGCOLOR
WriteDL(0xDB080000, 0x3E80C280) // set fog distance (float?)
WriteDL(0xE7000000, 0) // G_RDPPIPESYNC
// G_SETFILLCOLOR
if HICOLOR {
WriteDL(0xF7000000, 0x007FFFFF)
} else {
WriteDL(0xF7000000, 0x03FF03FF)
}
WriteDL(0xE7000000, 0) // G_RDPPIPESYNC
// G_FILLRECT coordinate order: (right, bottom), (top, left)
// note that the coordinates are all inclusive!

View File

@ -154,10 +154,14 @@ MainLoop:
sw t0, VI_Y_SCALE(a0)
j MainLoop
nop // delay slot
nop
SetupScreen:
ScreenNTSC(640, 480, BPP32|INTERLACE|AA_MODE_2, VIDEO_C_BUFFER | UNCACHED)
if HICOLOR {
ScreenNTSC(WIDTH, HEIGHT, BPP32|INTERLACE|AA_MODE_2|PIXEL_ADV_3, VIDEO_C_BUFFER | UNCACHED)
} else {
ScreenNTSC(WIDTH, HEIGHT, BPP16|AA_MODE_2|PIXEL_ADV_3, VIDEO_C_BUFFER | UNCACHED)
}
jr ra
nop