From acea55b89e8c5cd053cf5c42c77bf62021230251 Mon Sep 17 00:00:00 2001 From: Jeremy Janella Date: Sat, 5 Apr 2025 14:11:55 -0400 Subject: [PATCH] reduced ship pixel size to improve performance --- game.asm | 34 +++++++++++++++++++++++----------- graphics.pxo | Bin 1019 -> 1020 bytes 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/game.asm b/game.asm index b0ef205..d71b1f8 100644 --- a/game.asm +++ b/game.asm @@ -39,10 +39,10 @@ .data -# Store the offsets from the ship position. First 8 are pod, second 8 are service module, last 4 are legs. 20 pixels total -S: .word 8 12 516 520 524 528 1032 1036 1540 1544 1548 1552 2052 2056 2060 2064 2048 2068 2560 2580 +# Store the offsets from the ship position. First 2 are pod, second 4 are service module, last 2 are legs. 8 pixels total +S: .word 4 8 516 520 1028 1032 1536 1548 # Store the screen behind the ship -BH: .word 0:20 +BH: .word 0:8 sw $t8, 8($a0) # Layer 1 sw $t8, 12($a0) @@ -73,6 +73,7 @@ sw $t8, 8($a0) # Layer 1 .global main main: li $s0, BASE_ADDRESS # $s0 stores the base address for display + jal cBH jal lev0 li $s2, 0 # initial x velocity is 0 @@ -90,8 +91,8 @@ main1: main2: jal mship - # Sleep, 5Hz - li $a0, 200 + # Sleep, 50ms, 20Hz + li $a0, 50 li $v0, 32 syscall @@ -154,13 +155,24 @@ lev0: # Prepare level 0 addi $a0, $s0, 30220 # Draw medium platform jal dmp - addi $s1, $s0, 27160 # s1 stores the players position. 27984 is spawn + addi $s1, $s0, 28184 # s1 stores the players position. 27984 is spawn jal dship lw $t0, 0($sp) addi $sp, $sp, 4 # Return to main from the stack jr $t0 +cBH: # Clean bheind ship buffer + la $t0, BH # &B[i] + li $t1, 0 # Counter + sw 0x0, 0($t0) # B[i] = black + addi $t1, $t1, 1 + addi $t0, $t0, 4 + beq $t1, 8, cBH1 +cBH1: jr $ra + + + ss: # Set the screen li $t9, 0x0 # t9 holds the background color @@ -288,19 +300,19 @@ dship1: lw $t1, 0($t0) # t1 = S[i] sw $t8, 0($t2) # write the pixel addi $t0, $t0, 4 addi $t3, $t3, 1 - bne $t3, 8, dship1 + bne $t3, 2, dship1 dship2: lw $t1, 0($t0) # t1 = S[i] add $t2, $s1, $t1 # t2 = &write_to sw $t9, 0($t2) # write the pixel addi $t0, $t0, 4 addi $t3, $t3, 1 - bne $t3, 16, dship2 + bne $t3, 6, dship2 dship3: lw $t1, 0($t0) # t1 = S[i] add $t2, $s1, $t1 # t2 = &write_to sw $t7, 0($t2) # write the pixel addi $t0, $t0, 4 addi $t3, $t3, 1 - bne $t3, 20, dship3 + bne $t3, 8, dship3 jr $ra @@ -447,7 +459,7 @@ mship1: lw $t1, 0($t0) # t1 = S[i] addi $t0, $t0, 4 addi $t4, $t4, 4 addi $t3, $t3, 1 - bne $t3, 20, mship1 + bne $t3, 8, mship1 # Calculate the new position sll $t0, $s2, 2 @@ -471,7 +483,7 @@ mship2: lw $t1, 0($t0) # t1 = S[i] addi $t0, $t0, 4 addi $t4, $t4, 4 addi $t3, $t3, 1 - bne $t3,20, mship2 + bne $t3,8, mship2 # 3. draw the ship in the new position jal dship diff --git a/graphics.pxo b/graphics.pxo index a6c1b569c3a202fdae810841a5f6f7f17baf6207..aa3172275aab39cc5750578eb30fff5115e5c0d5 100644 GIT binary patch delta 250 zcmey({)e46z?+#xgn@yBgW;W2>qg!_Mj;>_wPnK96YPu(3=9nn4AKmf4={^O?qz15 ze2Q^iePYb@I{AOo{@m{T%ya(k&TUq=ztpW<_t$QFitoRVyAxNLrXTtJ`TxvMT3@Hs zM?Wl>_4?uOnB$SlqfWiv<1M^5XutO+|JvGr+l{A38cm;jzYAyw7H~jLmJ!8eQN8b( wE-?dDPJYH@#SC=fWMyU(PPkJiCont6gLp7yAh#={7<_T^er7W^QIHu702=mK2LJ#7 delta 250 zcmeyv{+pdQz?+#xgn@yBgTZ23%SPTlMj;>_Wt`cs!p6wJz|g?JAk8rOAhX!yK4$jG zrx@qeD_-4tzjeR*|FTCuhl|VCtvzSHH-1g_{?ltCC)fYUn~`-^^5efh^~?5n**?7= zW-%wN`iI@^!fPw1eX@Fg$z}bO_mkcP$It)&_Dt%uGpWzFD*^4m0yen2qc|+8_dU}k wW}rgG$uF2JnSoB6tio)<33uw`L}mwh5D%^ns8$)p;0u!vFq^T7fDB;(0P3MsjsO4v