TWIRL DEMO: a machine code analysis

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
David G
Posts: 545
Joined: Thu Jul 17, 2014 7:58 am
Location: 48 North

TWIRL DEMO: a machine code analysis

Post by David G »

TWIRL DEMO: a machine code analysis

Twirl Demo is an impressive display of a spinning cyclonic column ... like looking at the surface of a tornado. It is by Revival Studios, which has several newer (2012-2014) 16K games for the ZX81, even featuring Internet High Scores(?) ... by Martijn Wenting of the Netherlands. These are "killer games" for the ZX81


V I D E O: ZX81 16k: "Twirl" Demo
AEODG923tRc.jpg
This TWIRL demo contains a lot of ASCII text, not too surprising if this is a port from another platform. But what is the ASCII to ZX Text routine?


MACHINE CODE IN REM STATEMENT
-----------------------------
Uses a standard technique of machine code in REM 1

Code: Select all

1 REM REVIVAL COPY CLEAR 5 RNDLN STR$ RNDLN $INKEY$ GOSUB s
Uses a standard techniques to hide REM 1 from listing its contents
* first, using 7E to hide 5 bytes

Code: Select all

  db ZX_NUMBER    ;$7E (126) hide the next 5 bytes
  JP      $4092
  NOP	
  NOP
* Next has the text the author intended to display on LIST

Code: Select all

   1 REM REVIVAL
Although you can normally can not see this since the program is Autorun with (?) no way to exit to BASIC and list it. Using the "Disable Autorun" feature of ZXLister is one way to jailbreak it

* Finally, uses 76h to hide the rest

Code: Select all

dbzx 'REVIVAL'
db ZX_NEWLINE   ;76h (118)


CHARACTERS STRINGS USED
-----------------------
Strings identified using HexDump option of ZXLister

68B2h NO HIGHSCORE CODE

5034h *** TWIRL DEMO, BY REVIVAL STUDIOS *** (C)2010 ***

41DCh to 46AFh WELCOME TO THIS LITTLE TWIRL DEMO ... [1235 bytes of text]



ALTERNATE DISPLAY FILE
----------------------
Also seen in HexDump: an Alternate Display File at 46C2h, which looks like it contains all the initial visual data



ASCII TO ZX81
-------------
ASCII to ZX81 routine

Code: Select all

ASCII 'A' = 65 (41h)
ZX81  'A' = 38 (26h)
--------------------
            27 (1Bh)
So searching through the code I see 1BH used in two routines:
$6CD4 which appear to be a ZX to ASCII routine
$6D74 which is the ASCII to ZX81 routine, tested in the assembly file attached

The ZX to ASCII routine uses a table lookup for the punctuation characters. Interestingly it adopts a convention of mapping the apostrophe (which ZX81 does not have) to CHR 1 (the Northwest_Block character)
Attachments
ASCIIUTILS.p
sample program using ASCII TO TEXT routine
(1.14 KiB) Downloaded 72 times
ASCIIUTILS.ASM
Assembler file demonstrating ASCII TO TEXT routine
(7.23 KiB) Downloaded 104 times
Lardo Boffin
Posts: 2237
Joined: Sat Nov 26, 2016 2:42 am

Re: TWIRL DEMO: a machine code analysis

Post by Lardo Boffin »

Thats a hypnotic video!
ZX80
ZX81 iss 1 (bugged ROM, kludge fix, normal, rebuilt)
TS 1000 iss 3, ZXPand AY and +, ZX8-CCB, ZX-KDLX & ChromaSCART
Tatung 81 + Wespi
TS 1500 & 2000
Spectrum 16k (iss 1 s/n 862)
Spectrum 48ks plus a DIVMMC future and SPECTRA
David G
Posts: 545
Joined: Thu Jul 17, 2014 7:58 am
Location: 48 North

Re: TWIRL DEMO: a machine code analysis

Post by David G »

Lardo Boffin wrote: Sat Oct 05, 2024 10:47 am Thats a hypnotic video!
Yeah it is quite hypnotic


For all my talk, the one thing i didn't analyze was the main graphics, how is it done

alternate display files.png

There are three embedded alternate display files, I imagine these all swapped in/out of the display in a loop. But is there also some algorithm to rotate/transform the display?


By the way i was mistaken about the text, it is not ASCII, but is the native ZX81 character set
Attachments
character set display
character set display
hexdump shows the embedded display files
hexdump shows the embedded display files
Post Reply