Jump to content


Spider

Member Since 11 Apr 2014
Offline Last Active Jun 25 2019 12:26 PM
-----

#11137 source code for JSW

Posted by Norman Sword on 21 June 2019 - 12:59 PM

JET SET WILLY SOURCE CODE



I mentioned a long time ago that I would eventually upload a source code for Jet Set Willy. This I have done and the code is in the download section, under "other resources".

The version is Raw6jsw.asm but the 6 is just indicating that  6 steps were needed in its evolution from a disassembly

Hope its of use to someone.

The listing will assemble in Pasmo and output the game.... 




#11138 [File] Raw6jsw.zip

Posted by Norman Sword on 21 June 2019 - 01:56 PM

File Name: Raw6jsw.zip

File Submitter: Norman Sword

File Submitted: 21 Jun 2019

File Category: Other resources

System: N/A


This is just an assembly listing of Jet Set Willy, which is not the same as a disassembly.

 

Since this uses the skoolkit disassembly as its basis, It has been placed here so it is not viewable to none members.

 

The change from a disassembly makes the code a lot easier to understand and also a lot easier to edit.


Click here to download this file




#11107 Free space and code optimisation in "JSW"

Posted by IRF on 13 June 2019 - 06:38 AM

Thanks Norman. I notice that that method overwrites the intermediate byte twice, with the same value (not that it matters).




#11106 Free space and code optimisation in "JSW"

Posted by Norman Sword on 13 June 2019 - 12:17 AM

Small rewrite in the JSW game initialisation code which saves a byte:

 

87F5   LD HL,$857C     87F8   LD (HL),$30     87FA   INC HL     87FB   LD (HL),$30     87FD   INC HL     87FE   LD (HL),$30

 

LD HL, #857C

LD BC, #0330

loop:

LD (HL), C

INC HL

DJNZ loop

 

The simpler alternative is as follows

 

LD HL,#3030

LD (#857C),HL

LD (#857D),HL

9 bytes. Which is another byte shorter




#11096 Free space and code optimisation in "JSW"

Posted by IRF on 11 June 2019 - 12:33 PM

Small rewrite in the JSW game initialisation code which saves a byte:

 

87F5   LD HL,$857C     87F8   LD (HL),$30     87FA   INC HL     87FB   LD (HL),$30     87FD   INC HL     87FE   LD (HL),$30

 

LD HL, #857C

LD BC, #0330

loop:

LD (HL), C

INC HL

DJNZ loop




#11079 JSW Central

Posted by jetsetdanny on 29 May 2019 - 12:36 PM

Yes, exactly, I used SPECSAISIE Compare function. It's a very useful tool, indeed! :)




#11078 JSW Central

Posted by IRF on 29 May 2019 - 08:02 AM

Well done Danny!

 

I wonder if your statement here:

 


The two "Versions of the original JSW" pages dedicated to April Showers and Storm Warning Mix have been merged and are now a single entry (under the name Jet Set Willy: April Showers) as the comparison of their SNA files has confimed something I had long suspected: that there is no difference between them for the player.

 

was facilitated by your having utilised the SPECSAISIE comparison tool for the task?  (Which you recently installed and used in relation to the MM10CC project.)




#11076 [File] Jet Set Willy - Mark Woodmass's fast version

Posted by Norman Sword on 28 May 2019 - 06:02 PM

Checking the

 

ld hl,(counter)

Zilog claim 16T states. So that's good enough for me. 

This was not a clinical dissection, it was me wondering why the game ran so slow. With the heading a stack copy version of Jet Set Willy I was expecting a bit of zip in the movement.

The addition mistake and the subsequent error I will correct. 
=============================================

Just to be doubly sure I have dug out an old copy of Rodney Zaks. 

Page 334

16 T states

Attached Files




#11077 JSW Central

Posted by jetsetdanny on 29 May 2019 - 01:57 AM

I am pleased to announce that I have just launched a significant update of JSW Central. The highlights:

 

 

- The panel on the left side has been modified. It now provides direct access to the various game categories.

 

 

- A new category of "Mini Games" has been added to the main list. It currently has four entries: Andrew Broad's Jet Set Willy - Super Pre-School Edition (moved from the "Versions of the original JSW" section), John Elliott's Jet Set Willy 2: Super Pre-School Edition (new entry), the DrUnKeN mAsTeR's Jet Set Bulimic (new entry) and Ian Rushforth's Jet Set Willy Heaven and Hell (new entry). Although I do have some qualms - ironically, a game classified as a version of the original JSW (i.e. not a new game) can easily have more new rooms than a mini game (i.e. a new game) - adding the mini games section has solved my problem of where to list the three entries which were not part of any list on the site previously.

 

 

- Individual Manic Miner game pages have been modified. They now feature download links presented in the same way as on the other pages, short text introductions to most games and embedded YouTube videos. The way they are now is more or less what I would ultimately want each individual game page on JSW Central to look like.

 

 

- Individual pages of "Versions of the original MM" and "Versions of the original JSW" have been modified as well, mainly in the download links sections.

 

 

- Currently all individual game pages feature links to those games' pages on World of Spectrum and/or Spectrum Computing, as well as maps on Speccy Screenshot Maps, RZX walkthroughs on RZX Archive and YouTube videos (and links to their homepages if pertinent). The videos will continue to be embedded as work on the site progresses.

 

 

- Download links have been rearranged. There are now download folders for games in each category. Each of them has a subfolder called "dgd" (Direct Game Download). Most of them also have subfolders called "oth" (Other Downloads) and some have subfolders called "cen" (which stands for JSW Central Downloads).

 

In the Direct Game Download folders there are game files only (no text files, maps, etc.). Ideally, I would like to have a TAP and a TZX file for each pertinent version of each game. In rare cases where providing the files in such format was impossible, they are in another format (usually SNA or Z80). In any case, every game listed on the site can be downloaded from those folders in one format or another.

 

In the Other Downloads folders there are typically original ZIP files in the actual shape their authors released them in (most of them with the Readmes and many with other additions). In some cases original individual release files have been packed into one ZIP file (where the author did not release a ZIP, but some individual files only). This section will still be developed, because I can provide more of the original ZIPs, but I have to look for them among my files or on the internet. 

 

In the JSW Central Downloads folders there are files which reflect my creative input of some kind, if I may say so, such as bug-fixed or finished versions of games I have prepared for JSW Central, or RZX walkthroughs showing superior performances to their equivalents hosted on RZX Archive (i.e. the best publically available solutions to some games).

 

There are links to those files on the individual game pages. Furthermore, these folders are not protected in any way, so anyone can browse the Download folder and grab anything they need / want. So, as Gawp (Gary Pearce) once said on his website (on the Games Archive page, which doesn't always open from the direct link), "Download Willy games like there's no tomorrow!" :)

 

 

- Some individual game pages have been modified:

 

After further scrutiny, Jet Set Willy 25-100 has been promoted to the "Advanced modifications of the original JSW" category.

 

The sole entry in the Jet Set Willy II category has been split into two entries: Jet Set Willy II [by Derrick P. Rowson, Software Projects, 1985] and Jet Set Willy II+ [Derrick P. Rowson, 2016] (Version +e.22, 2017). I believe this reflects the reality better than just one entry for these two vastly different versions of the game.

 

The two "Versions of the original JSW" pages dedicated to April Showers and Storm Warning Mix have been merged and are now a single entry (under the name Jet Set Willy: April Showers) as the comparison of their SNA files has confimed something I had long suspected: that there is no difference between them for the player. In fact, the only difference between them in the range of addresses #8000-#FFFF is at #FEBB - #FED3, i.e. in code unused by the game, where the leftover Tandy code that reads, "© Copyright 1982 by LSI" in the original JSW and, consequently, also in the April Showers version, has been modified to read "RUSS J & DARREN S - JSW! " in the Storm Warning Mix version.

 

 

- Chronology has been updated up to the present moment and some earlier entries (related to the creation of versions of the original MM and JSW) have been added.

 
 
I will continue to develop JSW Centralgradually, as the real-world distractions permit. Please support this effort by letting me know about any games that are missing from it, any errors you find there and any suggestions for improvement you might have! :)



#11075 [File] Jet Set Willy - Mark Woodmass's fast version

Posted by IRF on 28 May 2019 - 02:47 PM


add iy,de        15T      76T
            ld hl,(counter)  16T      82T

 

76+16=92, but in any case doesn't the LD HL, (counter) require 20 T-States (source: http://z80-heaven.wi...ructions-set:ld )

 

Plugging that in yields about 8 T-States for the overhead per byte in the Stack Copy method, therefore a total of 18.5 T-States per byte.

i.e. the LDI method is even more efficient in comparison with the Stack Copy method than your rough calculations suggest(?)




#11074 [File] Jet Set Willy - Mark Woodmass's fast version

Posted by Norman Sword on 27 May 2019 - 08:57 PM

screen copies:-
 

Here I will talk about the main feature of this version, which is the usage of a stack copy routine.

Whilst the game is playing, the program has a multitude of screen data to copy. These copies are the main slowing down of the game. The amount of data that is copied consists of an attribute screen and a pixel or data screen. These are copied repeatedly. The order of copies might not be exactly as I write them out.

Each game loop:-
Starts by copying the Master Attribute area (512 bytes) to the working Attribute area of ram
It then copies the Master Pixel area (4096 bytes) to the working pixel area of ram

The body of game -- moves and draws the sprites

Then game loop continues and:-
Copies the  working pixel area of ram to the Viewable screen (4096 bytes)
Followed by the working attribute area of ram to the Viewable screen attribute area of ram (512 bytes)

Goes back and repeats each game loop


The above is moving for the copying of screens a total of 9216 bytes

 

This shows a lot of memory is copied on each game loop, and ways to speed this up, will have a dramatic effect on the games overall speed
So from here on I will partly discus the main methods for copying huge chunks of memory. The three most commonly used on a spectrum are
1) LDIR 2)LDI 3)stack copy. written in normal order of speed

 
The best way to look at a copying routine, is to look at how long each method takes to move one byte. A copy routine is after all just moving bytes of memory.
.

Here I will split the time into two parts, the first part is the time it takes to move the single byte in the idealised form. And then the overhead needed to perform the copy in a loop. The reason I split the timing is because the idealised part of the timing has to be performed. The idealised part will always be written and we have no option but to write and execute that part of the code. The overheads are the parts that can be changed by the programmer and the overheads are the programmers responsibility. 
.

The idealised speed of moving a single byte

The idealised times are the times that the basic op code(s) takes to move one byte  

Idealised times 

  LDIR      21 T states per byte

  LDI       16 T states per byte

Stack copy  - pop and push - 2 bytes  at 10.5 T states per byte
.
.

The overheads for the loop

 

With LDIR  their are no loop overheads. We set the up the data for the op code, then execute it. The LDIR executes its own internal loop

.
With LDI the main overheads are dictated by how much the LDI is rolled out.

Fastest possible loop, using inline code has only one op code to perform the loop.

With a stack copy we need lots of op codes to perform the loop. The amount used is up to the programmers imagination. Here the only code looked at, is the code used by Mark Woodmass.

Total time to move the byte adding the overheads

 

LDIR  -- this stays at 21 T-states, being the sum of the idealised op coded time and no overheads

.  

LDI -- this would normally be written as a loop macro- but for clarity I will write it out

I have picked a roll out of 32 LDI's, the more we have the faster it is. But having more and more rolled out brings decreasing gains. I have picked 32 as a good starting point. 

The copy loop using LDI

loop:

   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI
   LDI

           jp  pe,loop     10 T-states
.

here we have added for every 32 bytes moved a "jp pe,loop" into the loop overheads
.
This takes 10 T-states. This overhead is divided by how many bytes where moved in the loop
.

so the overheads are 10 T-state/32 or  0.3125 T-states  or (0.3 T-state approx) , so negligible compared to the 16 T-states of each byte moved.

This is moving a byte in around 16.3 T-states
.

.

.
Stack copy  using Pop push.

now lets look at the stack copy as used by Mark Woodmass

the body of the loop is

 

 

;          overhead           T-state / Total T-states

 

loop:

           ld sp,ix              10T  10T
 pop hl
 pop de
 pop bc
 pop af
          ex af,af'              4T  14T
          exx                    4T  18T
 pop hl
 pop de
 pop bc
 pop af
          ld sp,iy               10T  28T
 push af
 push bc
 push de
 push hl
           exx                   4T    32T
           ex af,af'             4T    36T
 push af
 push bc
 push de
 push hl
            ld de,$10        10T      46T
            add ix,de        15T      61T
            add iy,de        15T      76T
            ld hl,(counter)  16T      82T   92T  << correction of addition. (subsequent text altered to correct mistake)
            dec (hl)           11T      93T   103T
            jr nz,loop        12T      105T  115T

We move 16 bytes , but we have an overhead to add onto the pop and push ideal of 10.5 T-states

The overhead per byte is 115/16 T-states or  7.1875 T-states (7.2 approx)

This routine moves every byte at an idealised speed of 10.5 T-states, to which we now add the overheads per byte of 7.2 T-states.
Giving an overall speed of 17.7 T-states for each byte moved.

-------------------

Summery of total times taken to move a single byte in T-states

                  Total time                 Ideal Time               overheads

LDIR            21 T-states             21 T-states              0

LDI              16.3 T-states          16 T-states               0.3 

Stack Copy 17.7 T-states           10.5 T-states            7.2 T-states                    (Mark Woodmass version)

Stack Copy 13.1 T-states          10.5 T-states            2.6 T-states                    (last version I wrote. See addendum)
-------------------------
 

The version of stack copy used in this version of the game has managed to be slower than a very very simple rolled out LDI loop

This is a good example of being told that the stack copy method is the fastest method, and then writing some code to show how the version you write, manages to be slower.



*****************************************************************************************************************************************************
Addendum:-

In order to make a stack copy routine fast, we need to reduce the overheads to a minimum. This is best achieved by rolling the code out in a similar way that LDI is rolled out to cut the overheads. With stack copy rolling out the code consumes a lot of ram. But if we want the benefit of the speed the routine can bring. Then we must roll the code out and sacrifice the ram. 

In the last version of a stack copy I wrote. The main loop was slightly under 300 bytes in size. but the overheads per byte was around 2.6 T-states (the figures quoted are from a quick look at some of my code. the exact figures are unimportant. I am just trying to show how far the overheads can be reduced)
*****************************************************************************************************************************************************


** NOTE**  The idealised times for stack copy can be influenced by using the of IX and IY registers as part of the push pop registers. The above is an attempt at simplicity. We look only at the overheads and ignore the registers used. (I am not trying to explain in great detail) 

**NOTE** In the original timing for "LDI".  I used 1/3 this has been changed from 1/3 to .3. to correct inconsistency in numeric notation. 
 


 




#11073 JSW As Manufacturer (probably) intended .. kind of...

Posted by jetsetdanny on 25 May 2019 - 09:42 PM

How's your progress on the new version, Metalmickey? Is REV6 coming to these pages any time soon, by any chance? :)




#7958 JSW As Manufacturer (probably) intended .. kind of...

Posted by Metalmickey on 18 November 2017 - 08:25 PM

some more experimenting is required me thinks




#11072 [File] Jet Set Mini

Posted by jetsetdanny on 25 May 2019 - 05:39 PM

No, not yet. I'm still cool about it :).




#11070 [File] Jet Set Willy: Mono

Posted by jetsetdanny on 25 May 2019 - 04:12 AM

Very interesting comments, Ian - thanks!  :thumbsup: