From 48939bb3d481b43006e286f23610b3a2fc03aad8 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 24 Aug 2018 05:09:34 +0200 Subject: [PATCH] abstract width, height, and depth --- dlist.asm | 37 +++++++++++++++++++++++++++++++++---- main.asm | 8 ++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dlist.asm b/dlist.asm index bc68dab..eb377bf 100644 --- a/dlist.asm +++ b/dlist.asm @@ -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! diff --git a/main.asm b/main.asm index d17ee63..5d04f88 100644 --- a/main.asm +++ b/main.asm @@ -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