Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
NumBlocks CE: the 3D view's multiplications with fewer memory loads
Mason363ac2dee7d7dfb
diff --git a/games/numblocks/ce/src/main.c b/games/numblocks/ce/src/main.cindex 53cd8f89..73b8edd2 100644--- a/games/numblocks/ce/src/main.c+++ b/games/numblocks/ce/src/main.c@@ -326,6 +326,9 @@ int main(void) {{/* one picture, as the computer build makes it (to compare) */in_game = true, gui = GUI_NONE;+#ifdef NB_V7YAW+ pl.yaw = NB_V7YAW, pl.pitch = NB_V7PITCH;+#endifrender_frame();hud_draw();compose(true, true);@@ -333,10 +336,10 @@ int main(void) {plat_exit();}#endif-#if NB_BENCH >= 5 && NB_BENCH <= 6+#if NB_BENCH >= 5 && NB_BENCH <= 6 || NB_BENCH == 16{- /* rows of the window made (5: 16 of them, 6: none) */- for (int f = 0; f < (NB_BENCH == 5 ? 16 : 0); f++) {+ /* rows of the window made (5: 16 of them, 16: 64, 6: none) */+ for (int f = 0; f < (NB_BENCH == 5 ? 16 : NB_BENCH == 16 ? 64 : 0); f++) {pl.x += FX1;world_center(FXI(pl.x), FXI(pl.y) + 1, FXI(pl.z), false);while (world_busy()) world_step();diff --git a/games/numblocks/ce/src/rsb.inc b/games/numblocks/ce/src/rsb.incindex ac49844a..34edb32d 100644--- a/games/numblocks/ce/src/rsb.inc+++ b/games/numblocks/ce/src/rsb.inc@@ -114,10 +114,11 @@ b_span_alpha:; ------------------------------------------------------------------------------------------------- arithmetic; hl = hl x de >> 24: hl signed, de 0..2^24 (the low partial products left out)b_mulhi:- ld (m_a), hl+ push bcld (m_r), dexor a, ald (m_neg), a+ ld (m_a), hlld a, (m_a+2)bit 7, ajr z, .Lmh_pos@@ -128,60 +129,54 @@ b_mulhi:ld (m_a), hlld a, 1ld (m_neg), a-.Lmh_pos:- ; t = a2 r0 + a1 r1 + a0 r2ld a, (m_a+2)- ld h, a- ld a, (m_r)- ld l, a- mlt hl- ld a, (m_a+1)- ld d, a- ld a, (m_r+1)- ld e, a- mlt de+ ld de, (m_r)+.Lmh_pos:+ ; |a| in m_a: l a0, h a1, a a2; r: e r0, d r1, r2 at m_r+2. t = a2 r0 + a1 r1 + a0 r2+ ld c, a ; a2+ ld a, (m_r+2)+ ld b, a ; r2+ push de+ ld a, l ; a0+ ld l, d+ mlt hl ; a1 r1+ ld d, c+ mlt de ; a2 r0add hl, de- ld a, (m_a)ld d, a- ld a, (m_r+2)- ld e, a- mlt de+ ld e, b+ mlt de ; a0 r2add hl, deld (m_t), hlld hl, (m_t+1) ; t >> 8 (m_t+3 is 0)+ pop de; + a2 r1 + a1 r2- ld a, (m_a+2)- ld d, a- ld a, (m_r+1)- ld e, a- mlt de+ ld e, c+ mlt de ; a2 r1add hl, deld a, (m_a+1)ld d, a- ld a, (m_r+2)- ld e, a- mlt de+ ld e, b+ mlt de ; a1 r2add hl, de; + a2 r2 << 8- ld a, (m_a+2)- ld d, a- ld a, (m_r+2)- ld e, a+ ld d, c+ ld e, bmlt de+ ld (m_t+1), de ; (de's top byte is 0 after mlt: m_t+3 stays 0)xor a, ald (m_t), a- ld (m_t+1), de ; (de's top byte is 0 after mlt: m_t+3 stays 0)ld de, (m_t)add hl, de+ pop bcjr b_neg_if-; hl = hl x a >> 8: hl signed, a 0..255+; hl = hl x a >> 8: hl signed, a 0..255 (b kept)b_mul8:- ld (m_f), a+ ld c, a ; fld (m_a), hl- xor a, a- ld (m_neg), ald a, (m_a+2)+ ld (m_f), a ; (its top bit: negative)bit 7, ajr z, .Lm8_posex de, hl@@ -189,35 +184,31 @@ b_mul8:sbc hl, hlsbc hl, deld (m_a), hl- ld a, 1- ld (m_neg), a-.Lm8_pos:- ; (s0 f >> 8) + s1 f + (s2 f << 8)- ld a, (m_f)- ld e, a- ld a, (m_a)- ld d, a- mlt de ; s0 f- ld c, d ; s0 f >> 8- ld a, (m_f)- ld e, ald a, (m_a+2)+.Lm8_pos:+ ; (s2 f << 8) + (s0 f >> 8) + s1 fld d, a+ ld e, cmlt de ; s2 f- xor a, a+ ld (m_t+1), de ; (m_t+3 stays 0)+ ld e, h ; s1+ ld h, c+ mlt hl ; s0 f+ ld a, hld (m_t), a- ld (m_t+1), de- ld hl, (m_t) ; s2 f << 8- ld a, (m_f)- ld e, a- ld a, (m_a+1)- ld d, a+ ld d, cmlt de ; s1 f+ ld hl, (m_t)add hl, de- ld de, 0- ld e, c- add hl, de- ; (fall through)+ ld a, (m_f)+ bit 7, a+ ret z+ ex de, hl+ or a, a+ sbc hl, hl+ sbc hl, de+ ret+b_neg_if:ld a, (m_neg)or a, a