Discussion:
Small Tetris
(too old to reply)
Kerr-Mudd, John
2021-11-21 13:50:31 UTC
Permalink
I've been looking at small tetris games; doable in <256 bytes; I'm at
241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
--
Bah, and indeed Humbug.
Kerr-Mudd, John
2021-12-04 16:01:25 UTC
Permalink
On Sat, 4 Dec 2021 14:08:42 +0000
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm
at 241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
Dropping & scoring (up to 9!) added. still 17 bytes spare!
There's also a(n unavoidable?) bigjumpback in there that wastes 3.
If I could only make the keyin rtn shorter.
[]
Sorry if it wraps: here's one where you can max out at 99!
(but only 1 byte left)

[I've copied in dos programmer]

-> d 100 l100
16A5:0100 40 CD 10 68-00 B8 07 06-1F 41 E4 40-83 E0 07 BB @***@....
16A5:0110 08 08 08 C7-89 C5 8A 86-F7 01 C1 E0-04 95 BF C0 ................
16A5:0120 FF E3 04 E2-05 B1 0A 83-C7 50 60 BF-80 07 B1 0C .........P`.....
16A5:0130 B8 DB 08 8A-1E 1E 00 F3-AB BE 32 07-83 EF 68 B1 ..........2...h.
16A5:0140 0A B2 08 AB-A4 22 14 A4-E2 FA AB 74-04 83 C7 50 .....".....t...P
16A5:0150 43 83 EE 64-73 E6 BF 1C-00 88 D8 80-EB 3A 72 07 C..ds........:r.
16A5:0160 FE 05 80 0D-30 88 D8 AF-0C 30 AA 61-B4 01 CD 16 ....0....0.a....
16A5:0170 74 0A B4 00-CD 16 88 E0-3C 01 74 58-57 3C 4D 75 t.......<.tXW<Mu
16A5:0180 01 AF 3C 4B-75 02 4F 4F-55 3C 48 74-55 3C 50 75 ..<Ku.OOU<HtU<Pu
16A5:0190 02 31 C9 99-E8 20 00 75-41 5A 5A BA-DA 03 89 D8 .1... .uAZZ.....
16A5:01A0 E8 14 00 74-03 E9 61 FF-51 B1 06 EC-A8 08 74 FB ...t..a.Q.....t.
16A5:01B0 E2 F9 91 59-68 21 01 60-B1 10 F6 C1-03 75 03 83 ...Yh!.`.....u..
16A5:01C0 C7 48 D1 C5-73 11 08 D2-74 0B AB 0A-75 4E E2 EA .H..s...t...uN..
16A5:01D0 F6 C6 08 61-C3 0A 35 AF-EB F4 5D 5F-83 FF C0 75 ...a..5...]_...u
16A5:01E0 BA C3 51 B1-10 B8 11 11-C1 C5 04 D1-D0 73 02 D1 ..Q..........s..
16A5:01F0 CD E2 F5 95-59 EB 9C 0F-74 36 72 63-71 33 0F 00 ....Y...t6rcq3..
--
Bah, and indeed Humbug.
Kerr-Mudd, John
2021-12-04 20:44:01 UTC
Permalink
On Sat, 4 Dec 2021 16:01:25 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 14:08:42 +0000
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm
at 241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
Dropping & scoring (up to 9!) added. still 17 bytes spare!
There's also a(n unavoidable?) bigjumpback in there that wastes 3.
If I could only make the keyin rtn shorter.
[]
Sorry if it wraps: here's one where you can max out the score at 99!
(but only 1 byte left)
[I've copied in dos programmer]
/msdos/
Post by Kerr-Mudd, John
-> d 100 l100
16A5:0110 08 08 08 C7-89 C5 8A 86-F7 01 C1 E0-04 95 BF C0 ................
16A5:0120 FF E3 04 E2-05 B1 0A 83-C7 50 60 BF-80 07 B1 0C .........P`.....
16A5:0130 B8 DB 08 8A-1E 1E 00 F3-AB BE 32 07-83 EF 68 B1 ..........2...h.
16A5:0140 0A B2 08 AB-A4 22 14 A4-E2 FA AB 74-04 83 C7 50 .....".....t...P
16A5:0150 43 83 EE 64-73 E6 BF 1C-00 88 D8 80-EB 3A 72 07 C..ds........:r.
16A5:0160 FE 05 80 0D-30 88 D8 AF-0C 30 AA 61-B4 01 CD 16 ....0....0.a....
16A5:0170 74 0A B4 00-CD 16 88 E0-3C 01 74 58-57 3C 4D 75 t.......<.tXW<Mu
16A5:0180 01 AF 3C 4B-75 02 4F 4F-55 3C 48 74-55 3C 50 75 ..<Ku.OOU<HtU<Pu
16A5:0190 02 31 C9 99-E8 20 00 75-41 5A 5A BA-DA 03 89 D8 .1... .uAZZ.....
16A5:01A0 E8 14 00 74-03 E9 61 FF-51 B1 06 EC-A8 08 74 FB ...t..a.Q.....t.
16A5:01B0 E2 F9 91 59-68 21 01 60-B1 10 F6 C1-03 75 03 83 ...Yh!.`.....u..
16A5:01C0 C7 48 D1 C5-73 11 08 D2-74 0B AB 0A-75 4E E2 EA .H..s...t...uN..
16A5:01D0 F6 C6 08 61-C3 0A 35 AF-EB F4 5D 5F-83 FF C0 75 ...a..5...]_...u
16A5:01E0 BA C3 51 B1-10 B8 11 11-C1 C5 04 D1-D0 73 02 D1 ..Q..........s..
16A5:01F0 CD E2 F5 95-59 EB 9C 0F-74 36 72 63-71 33 0F 00 ....Y...t6rcq3..
--
Bah, and indeed Humbug.
Kerr-Mudd, John
2021-12-14 10:25:17 UTC
Permalink
On Sat, 4 Dec 2021 20:44:01 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 16:01:25 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 14:08:42 +0000
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm
at 241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
Dropping & scoring (up to 9!) added. still 17 bytes spare!
There's also a(n unavoidable?) bigjumpback in there that wastes 3.
If I could only make the keyin rtn shorter.
[]
Sorry if it wraps: here's one where you can max out the score at 99!
(but only 1 byte left)
[I've copied in dos programmer]
/msdos/
More robust version (doesn't rely on ax=0, ch=0 at start, or trailing 0)

-> d 100 l100
162E:0100 B8 01 00 89-C1 CD 10 68-00 B8 07 06-1F E4 40 83 ***@.
162E:0110 E0 07 BB 08-08 08 C7 95-8B AE F5 01-81 E5 F0 0F ................
162E:0120 41 BF C0 FF-E3 04 E2 05-B1 0A 83 C7-50 60 BF 80 A...........P`..
162E:0130 07 B1 0C B8-DB 08 F3 AB-BE 32 07 8A-16 1E 00 83 .........2......
162E:0140 EF 68 B1 0A-B6 08 AB A4-22 34 A4 E2-FA AB 74 04 .h......"4....t.
162E:0150 83 C7 50 42-83 EE 64 73-E6 BF 1C 00-92 3C 3A 72 ..PB..ds.....<:r
162E:0160 07 2C 0A FE-05 80 0D 30-AF 0C 30 AA-61 B4 01 CD .,.....0..0.a...
162E:0170 16 74 09 98-CD 16 88 E0-3C 01 74 57-57 3C 4D 75 .t......<.tWW<Mu
162E:0180 01 AF 3C 4B-75 02 4F 4F-55 3C 48 74-4C 3C 50 75 ..<Ku.OOU<HtL<Pu
162E:0190 02 31 C9 99-89 D8 E8 1E-00 75 53 5A-5A BA DA 03 .1.......uSZZ...
162E:01A0 E8 14 00 74-03 E9 65 FF-51 B1 06 EC-A8 08 74 FB ...t..e.Q.....t.
162E:01B0 E2 F9 91 59-68 24 01 60-B1 10 F6 C1-03 75 03 83 ...Yh$.`.....u..
162E:01C0 C7 48 D1 C5-73 10 08 D2-74 0A AB 0A-75 4E E2 EA .H..s...t...uN..
162E:01D0 84 C6 61 C3-0A 35 AF EB-F5 51 B1 10-B8 11 11 C1 ..a..5...Q......
162E:01E0 C5 04 D1 D0-73 02 D1 CD-E2 F5 95 59-EB A5 5D 5F ....s......Y..]_
162E:01F0 83 FF C0 75-A8 C3 66 36-16 27 47 F7-F0 00 00 00 ...u..f6.'G.....
Post by Kerr-Mudd, John
--
Bah, and indeed Humbug.
--
Bah, and indeed Humbug.
Kerr-Mudd, John
2023-05-19 17:18:18 UTC
Permalink
On Tue, 14 Dec 2021 10:25:17 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 20:44:01 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 16:01:25 +0000
Post by Kerr-Mudd, John
On Sat, 4 Dec 2021 14:08:42 +0000
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm
at 241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
Dropping & scoring (up to 9!) added. still 17 bytes spare!
There's also a(n unavoidable?) bigjumpback in there that wastes 3.
If I could only make the keyin rtn shorter.
[]
Sorry if it wraps: here's one where you can max out the score at 99!
(but only 1 byte left)
[I've copied in dos programmer]
/msdos/
Revisited: now a pure 8086 version (previous ones require 186 for push
value; rol reg,num; and pusha/popa)

255 bytes: still 1 long jmp and 4 lots of push pop cx, so maybe a few bytes
still to squeeze out. Oh, scoring is now unrestricted. No sounds or
speedup, just std play with csr keys (and Esc)

-> d 100 l100
1632:0100 40 CD 10 B7-B8 53 07 06-1F E4 40 83-E0 07 BB 08 @***@.....
1632:0110 08 08 C7 95-8B AE F6 01-81 E5 F0 0F-41 BF DC FF ............A...
1632:0120 E3 04 E2 05-B1 0A 83 C7-50 57 55 51-57 BF 9C 07 ........PWUQW...
1632:0130 B1 0C B8 DB-08 F3 AB BE-4E 07 83 EF-68 B1 0A B6 ........N...h...
1632:0140 08 AB A4 22-34 A4 E2 FA-AB 74 19 83-C7 50 53 50 ..."4....t...PSP
1632:0150 BB 42 00 4B-4B B0 30 86-07 0C 10 3C-39 74 F4 40 .B.KK.0....<9t.@
1632:0160 88 07 58 5B-83 EE 64 73-D1 5F 59 B4-01 CD 16 74 ..X[..ds._Y....t
1632:0170 33 98 CD 16-88 E0 3C 01-74 6D 3C 50-75 02 31 C9 3.....<.tm<Pu.1.
1632:0180 3C 4D 75 01-AF 3C 4B 75-02 4F 4F 3C-48 75 15 51 <Mu..<Ku.OO<Hu.Q
1632:0190 B9 04 10 B8-11 11 D3 C5-D1 D0 73 02-D1 CD FE CD ..........s.....
1632:01A0 75 F4 95 59-99 89 D8 E8-1F 00 75 43-5A 5A BA DA u..Y......uCZZ..
1632:01B0 03 E8 15 00-74 03 E9 50-FF 51 B1 06-EC A8 08 74 ....t..P.Q.....t
1632:01C0 FB E2 F9 91-59 BE 20 01-56 51 52 57-B1 10 F6 C1 ....Y. .VQRW....
1632:01D0 03 75 03 83-C7 48 D1 C5-73 12 08 D2-74 0C AB 0A .u...H..s...t...
1632:01E0 75 4E E2 EA-84 C6 5F 5A-59 C3 0A 35-AF EB F3 5D uN...._ZY..5...]
1632:01F0 5F 83 FF DC-75 B8 C3 2C-37 16 F7 40-F7 60 03 00 _...u..,***@.`..
--
Bah, and indeed Humbug.
Jim Leonard
2021-12-12 19:58:23 UTC
Permalink
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm at
241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
It would be more interesting, and less mangled, for you to post the .asm source instead of a binary hex dump.
Kerr-Mudd, John
2021-12-12 21:52:31 UTC
Permalink
On Sun, 12 Dec 2021 11:58:23 -0800 (PST)
Post by Jim Leonard
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm at
241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
It would be more interesting, and less mangled, for you to post the .asm source instead of a binary hex dump.
Where's the fun in that?
OK you can have a 'u' debug dump for a bit of clarity.
I've improved it slightly; I have 7 spare bytes now, so this doesn't match the previous hexdump.
Note the cunning use of /movsb/ to move through the lines; often copying in place!
also that /bright/=blockchar (8)


; assumes ax=0 ,ss=ds on entry, also that int 10 puts spaces (0x20) to screen area
->u 100 l100
162E:0100 40 inc ax
162E:0101 CD 10 int 10
162E:0103 68 00 B8 push B800
162E:0106 07 pop es
162E:0107 06 push es
162E:0108 1F pop ds
162E:0109 E4 40 in al,40
162E:010B 83 E0 07 and ax,0007
162E:010E BB 08 08 mov bx,0808
162E:0111 08 C7 or bh,al
162E:0113 95 xchg ax,bp
162E:0114 8B AE F1 01 mov bp,[bp+01F1]
162E:0118 81 E5 F0 0F and bp,0FF0
162E:011C 41 inc cx
162E:011D BF C0 FF mov di,FFC0
162E:0120 E3 04 jcxzw 0126
162E:0122 E2 05 loopw 0129
162E:0124 B1 0A mov cl,0A
162E:0126 83 C7 50 add di,0050
162E:0129 60 pushaw
162E:012A BF 80 07 mov di,0780
162E:012D B1 0C mov cl,0C
162E:012F B8 DB 08 mov ax,08DB
162E:0132 F3 AB repz stosw
162E:0134 BE 32 07 mov si,0732
162E:0137 8A 16 1E 00 mov dl,[001E]
162E:013B 83 EF 68 sub di,0068
162E:013E B1 0A mov cl,0A
162E:0140 B6 08 mov dh,08
162E:0142 AB stosw
162E:0143 A4 movsb
162E:0144 22 34 and dh,[si]
162E:0146 A4 movsb
162E:0147 E2 FA loopw 0143
162E:0149 AB stosw
162E:014A 74 04 jz 0150
162E:014C 83 C7 50 add di,0050
162E:014F 42 inc dx
162E:0150 83 EE 64 sub si,0064
162E:0153 73 E6 jnb 013B
162E:0155 BF 1C 00 mov di,001C
162E:0158 92 xchg ax,dx
162E:0159 3C 3A cmp al,3A
162E:015B 72 07 jb 0164
162E:015D 2C 0A sub al,0A
162E:015F FE 05 inc byte [di]
162E:0161 80 0D 30 or byte [di],30
162E:0164 AF scasw
162E:0165 0C 30 or al,30
162E:0167 AA stosb
162E:0168 61 popaw
162E:0169 B4 01 mov ah,01
162E:016B CD 16 int 16
162E:016D 74 09 jz 0178
162E:016F 98 cbw
162E:0170 CD 16 int 16
162E:0172 88 E0 mov al,ah
162E:0174 3C 01 cmp al,01
162E:0176 74 57 jz 01CF
162E:0178 57 push di
162E:0179 3C 4D cmp al,4D
162E:017B 75 01 jnz 017E
162E:017D AF scasw
162E:017E 3C 4B cmp al,4B
162E:0180 75 02 jnz 0184
162E:0182 4F dec di
162E:0183 4F dec di
162E:0184 55 push bp
162E:0185 3C 48 cmp al,48
162E:0187 74 4C jz 01D5
162E:0189 3C 50 cmp al,50
162E:018B 75 02 jnz 018F
162E:018D 31 C9 xor cx,cx
162E:018F 99 cwd
162E:0190 89 D8 mov ax,bx
162E:0192 E8 1E 00 call 01B3
162E:0195 75 53 jnz 01EA
162E:0197 5A pop dx
162E:0198 5A pop dx
162E:0199 BA DA 03 mov dx,03DA
162E:019C E8 14 00 call 01B3
162E:019F 74 03 jz 01A4
162E:01A1 E9 65 FF jmp 0109
162E:01A4 51 push cx
162E:01A5 B1 06 mov cl,06
162E:01A7 EC in al,dx
162E:01A8 A8 08 test al,08
162E:01AA 74 FB jz 01A7
162E:01AC E2 F9 loopw 01A7
162E:01AE 91 xchg ax,cx
162E:01AF 59 pop cx
162E:01B0 68 20 01 push 0120
162E:01B3 60 pushaw
162E:01B4 B1 10 mov cl,10
162E:01B6 F6 C1 03 test cl,03
162E:01B9 75 03 jnz 01BE
162E:01BB 83 C7 48 add di,0048
162E:01BE D1 C5 rol bp,1
162E:01C0 73 10 jnb 01D2
162E:01C2 08 D2 or dl,dl
162E:01C4 74 0A jz 01D0
162E:01C6 AB stosw
162E:01C7 0A 75 4E or dh,[di+4E]
162E:01CA E2 EA loopw 01B6
162E:01CC 84 C6 test dh,al
162E:01CE 61 popaw
162E:01CF C3 ret
162E:01D0 0A 35 or dh,[di]
162E:01D2 AF scasw
162E:01D3 EB F5 jmp 01CA
162E:01D5 51 push cx
162E:01D6 B1 10 mov cl,10
162E:01D8 B8 11 11 mov ax,1111
162E:01DB C1 C5 04 rol bp,04
162E:01DE D1 D0 rcl ax,1
162E:01E0 73 02 jnb 01E4
162E:01E2 D1 CD ror bp,1
162E:01E4 E2 F5 loopw 01DB
162E:01E6 95 xchg ax,bp
162E:01E7 59 pop cx
162E:01E8 EB A5 jmp 018F
162E:01EA 5D pop bp
162E:01EB 5F pop di
162E:01EC 83 FF C0 cmp di,FFC0
162E:01EF 75 A8 jnz 0199
162E:01F1 C3 ret
162E:01F2 66 36 16 ss:push ss
162E:01F5 27 daa
162E:01F6 47 inc di
162E:01F7 F7 F0 div ax

Those last 8 bytes (yes, including the ret!) encode the tetris shape data
--
Bah, and indeed Humbug.
Terje Mathisen
2021-12-13 14:36:25 UTC
Permalink
Post by Kerr-Mudd, John
On Sun, 12 Dec 2021 11:58:23 -0800 (PST)
Post by Jim Leonard
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm at
241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
It would be more interesting, and less mangled, for you to post the .asm source instead of a binary hex dump.
Where's the fun in that?
OK you can have a 'u' debug dump for a bit of clarity.
I've improved it slightly; I have 7 spare bytes now, so this doesn't match the previous hexdump.
Note the cunning use of /movsb/ to move through the lines; often copying in place!
also that /bright/=blockchar (8)
; assumes ax=0 ,ss=ds on entry, also that int 10 puts spaces (0x20) to screen area
->u 100 l100
162E:0100 40 inc ax
162E:0101 CD 10 int 10
[snip]
Post by Kerr-Mudd, John
162E:01EF 75 A8 jnz 0199
162E:01F1 C3 ret
162E:01F2 66 36 16 ss:push ss
162E:01F5 27 daa
162E:01F6 47 inc di
162E:01F7 F7 F0 div ax
Those last 8 bytes (yes, including the ret!) encode the tetris shape data
That's very impressive John!

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Kerr-Mudd, John
2021-12-13 16:04:05 UTC
Permalink
On Mon, 13 Dec 2021 15:36:25 +0100
Post by Terje Mathisen
Post by Kerr-Mudd, John
On Sun, 12 Dec 2021 11:58:23 -0800 (PST)
Post by Jim Leonard
On Sun, 21 Nov 2021 13:50:31 +0000
Post by Kerr-Mudd, John
I've been looking at small tetris games; doable in <256 bytes; I'm at
241 (219 with a different look), I'll look at adding "drop" and
maybe scoring.
It would be more interesting, and less mangled, for you to post the .asm source instead of a binary hex dump.
Where's the fun in that?
OK you can have a 'u' debug dump for a bit of clarity.
I've improved it slightly; I have 7 spare bytes now, so this doesn't match the previous hexdump.
Note the cunning use of /movsb/ to move through the lines; often copying in place!
also that /bright/=blockchar (8)
; assumes ax=0 ,ss=ds on entry, also that int 10 puts spaces (0x20) to screen area
Actually it also requires ch=0 on entry; fixing that takes another 2 bytes. But I have 6 leftover so it could be done.
Post by Terje Mathisen
Post by Kerr-Mudd, John
->u 100 l100
162E:0100 40 inc ax
162E:0101 CD 10 int 10
[snip]
Post by Kerr-Mudd, John
162E:01EF 75 A8 jnz 0199
162E:01F1 C3 ret
162E:01F2 66 36 16 ss:push ss
162E:01F5 27 daa
162E:01F6 47 inc di
162E:01F7 F7 F0 div ax
Those last 8 bytes (yes, including the ret!) encode the tetris shape data
That's very impressive John!
Terje
Thanks. I saw a demoscene version from a chap in Hungary:
https://www.pouet.net/prod.php?which=6951
but that only has 6 shapes, no scoring, no dropping, so I thought I'd see if I could do better

Mine is based on James David Chapman's 1999 /tet.asm/ which I'd made smaller a year or 2 back.
https://comp.lang.asm.x86.narkive.com/tdwb6WKq/pong-256
--
Bah, and indeed Humbug.
Loading...