Jet Set Willy II Music

Page 4/5
1 | 2 | 3 | | 5

By z80 coder

Supporter (5)

z80 coder's picture

25-04-2013, 12:39

The sudoku solution listed is the one I changed... Here is the changed logic... Sorry my version is missing bits of unimportant code. specific to the program it came from.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' converted from MSX basic to QBASIC .
'
' speed gains:: an early version took 10:53 to solve a grid
' this version solves same grid in under 00:01 sec
'
'
' There are three arrays used here to speed up the solving
'infl(80,20),infl2(80,21) and shadow(80)
'
'infl(80,20) this is an array that holds the INFLuence of each tile on the
' rest of the grid. The original method works out each and every loop these
' tiles. This array is generated ONCE per session. It finds the three sets of
' influence for a tile removes duplicate tiles and orders then numerically
' this reduces the tile scan count from 3*9=27 to 21. not much reduction,but
' it removes the repetitive calculations and that is a massive reduction.
' 25% plus faster on that part of the solution
' the generation of this array is not included here
'
'infl2(80,21) this array is taken from the infl(80,20) array. What it does is
'removes tiles from "need to be checked" if its value is higher than the
'original and is blank. e.g. when solving by brute force the tried solutions
'start at the top of the grid and work down. That means unless the tile lower
'down already has a value, there is no need to check it
' this removal of redundant checking is worth the speed gain.
' up to 10% faster on that part of the solution
'
'Shadow(80) since I am drawing the grid every so often and I am repeatedly
'drawing the grid ontop of itself. There is no point in putting the same
'information down on the same spot. The original code drew the grid every loop
' I draw the grid every 10000 loops. Still worth the effort of not drawing
' the same graphic over and over again
'
'Other changes are just structual
'
'DATA 000600200
'DATA 804030000
'DATA 000009000
'DATA 405000007
'DATA 710000000
'DATA 003050008
'DATA 300070004
'DATA 000001900
'DATA 000200060
'
' try solving the above grid and see why this brute force method needs
' to be speeded up
'
'
'
'
'
' No logic, just brute force solve
'
bruteforce:
' on entry the game board is copied into the force solve board array
' a Flag DEMO is set to either 0=(solve and ask) or 1=(just solve)
TIME$ = "00:00:00"
FOR i = 0 TO 9: digit(i) = 0: NEXT i ' 10 digit loop counter
FOR i = 0 TO 81: shadow(i) = -1: NEXT i ' only redraw changed tiles
ix = 460: iy = 200: boxs 460, 200 ' draw sudoku grid
text 450, 182, "SOLVING BOARD USING" ' info text
text 450, 188, " FORCE METHOD "
'
'
' rewrite of structure removing xy references
' Create list from data and count empty cells
' counting empty cells/copying positions and copying start grid
ec = 0 ' Number of empty cells
'EX() empty cell positions
'gp() cell values
FOR i = 0 TO 80
a = tp(i).v 'game grid
gp(i) = a 'solver grid
IF a = 0 THEN ex(ec) = i: ec = ec + 1 ' if blank then store position
NEXT i
' Initialize solving loop
ep = 0 ' Empty cell pointer
mp = 0 ' Previous moves pointer
CI = 0 ' Candidate index pointer
'
'generate the custom array using existing infl array
' this drops a 1:04 search to 0:50
FOR i = 0 TO 80
count = 0
FOR x = 0 TO 20
a = infl%(i, x)
IF a < i THEN ' if value lower than must be set
infl2%(i, count) = a: count = count + 1
ELSE
spot = gp(a) ' else find if it "COULD" have a value
IF spot > 0 THEN
infl2%(i, count) = a: count = count + 1
END IF
END IF
NEXT x
infl2(i, 21) = count - 1 ' store grand total
NEXT i
'
'
LOCATE 1, 1
PRINT "Start solving loop..." + STRING$(32, 32)
'
forcesolve:
' permit abort of scanning
IF INKEY$ = " " THEN GOSUB showingboard: RETURN ' not solved "aborted"
IF ep > ec - 1 THEN GOSUB showingboard: GOSUB askfill: RETURN 'solved
x = ex(ep) ' Get location for current empty cell
' Obtain candidates in cl array
FOR i = 1 TO 9 ' clear candidates
cl(i) = i
NEXT i
'use influence array (it's a lot quicker)
count = infl2%(x, 21)
FOR i = 0 TO count
tile = infl2%(x, i)
a = gp(tile)
cl(a) = 0
NEXT i
' Sequence the cl array and count instances
CO = 0 ' Number of instances
' this count and clear method works because the initial array starts at 1
' the final array starts at 0: so erase will not overwrite wanted data
' in fact no need to even clear data
FOR i = 1 TO 9:
IF cl(i) THEN cl(CO) = i: CO = CO + 1
NEXT i
' Check candidates
IF CO > CI THEN GOTO insertvalue
ep = ep - 1: IF ep < 0 THEN GOTO BoardError
mp = mp - 1: IF mp < 0 THEN GOTO BoardError
CI = PI(mp) + 1
gp(ex(ep)) = 0
GOTO forcesolve

'put number in grid
insertvalue:
gp(x) = cl(CI)
PI(mp) = CI ' Add this move to the previous moves lists
mp = mp + 1
CI = 0 ' Reset cIndex
ep = ep + 1 ' Advance to the next cell
' intermittantly show the board data "NOT EVRY LOOP"
bump = 0 ' set the counter flag
bumpcounter 10, 7 ' this routine counts using "10" digits
' if the "7" digit changes then bump=1
IF bump = 1 THEN ' every 10000 loops show board
GOSUB showingboard
END IF
GOTO forcesolve

BoardError:
IF demo = 0 THEN
WHILE INKEY$ = ""
LOCATE 1, 1: PRINT "(board structure error)"
delay 1
LOCATE 1, 1: PRINT "(board error)"
delay 1
WEND
END IF
demo = 2
ep = ec
GOTO forcesolve

'

showingboard:
showcounter ix - 5, iy + 64, 10 ' subroutine prints counter
a$ = TIME$: text ix, iy + 72, a$ ' subroutine prints clock
tinytot = 7
FOR a = 0 TO 80
spot = gp(a) + 10: B = shadow(a)
IF spot <> B THEN
shadow(a) = spot
'grid pos
zy = (a \ 9) * tinytot + iy
zx = (a MOD 9) * tinytot + ix
PUT (zx, zy), tiny(spot * tinysize), PSET 'draw graphic
END IF
NEXT a
RETURN

askfill:
GOSUB showingboard
IF demo THEN GOTO demoexit
LOCATE 1, 1
PRINT "insert the solution (y) any other key aborts "
a$ = "": WHILE a$ = "": a$ = INKEY$: WEND
IF UCASE$(a$) = "Y" THEN
' this loop copies the solution into the true game grid
FOR tile = 0 TO 80
IF tp(tile).v = 0 THEN ' copy to unsolved squares only
spot = gp(tile) ' get possible solution value
tp(tile).v = spot ' possible solution move to game grid
tp(tile).ov = -1 ' flag redraw
tp(tile).f = 2 ^ spot ' set game flag
placetile tile, 0, 0 ' print out a tile
END IF
NEXT tile
END IF
demoexit:
IF demo = 1 THEN text 450, 182, " SOLVED BOARD USING"
IF demo = 2 THEN text 450, 182, " structure error "
LOCATE 1, 1
PRINT STRING$(79, 32) ' (tidy up) clear top line of screen
RETURN

By nikodr

Paladin (724)

nikodr's picture

25-04-2013, 23:03

Hello z80 codercoder so nice to share those memoriesSmile i have arequest since all those games were hardcoded and highly optimized because ram was not enough back then shoykdnt we hack and change something?the music is nice but is the same and after some time one has to mute the audio because it plays the same piece.couldnt we just create new pieces maybe with greater duration?many people have lot more ram than back then.do you have any commented sources of that game for msx?it could be nice if someone could create more melodies.
I know it may sound weirs for some.but nowdays we have much more technical advantages to create code for old micros
Kind regarda

By MäSäXi

Paragon (1884)

MäSäXi's picture

27-04-2013, 07:53

I actually like ingame music in both Jet Set Willy games (talking about original versions), but you have really interesting idea, nikodr! It doesn´t sound weird at all. Spectrum has many many Jet Set Willy hacks, hopefully MSX can have some special version now too! Smile

Are you thinking longer PSG tune(s) or longer MSX-Music or Moonsound tunes? Personally I prefer PSG, for nostalgic reasons. Smile But MSX-Music is a nice idea too. I don´t have Moonsound and I think many fans of Jet Set Willy don´t have it either. Question

If someone hopefully gets interested in nikodr´s idea, I hope new tune(s) + hacked original game will not exceed 64K to make it run on MSX(1). Smile It feels a bit strange to have otherwise non-modified Jet Set Willy II running only on 128K MSX2.

Also, for nostalgic reasons, I hope new tunes will be classical music. Smile Composed to sound like classical music, not rock/rap/jazz whatever alt. versions of classical music songs, to keep game´s original feeling. Smile

By nikodr

Paladin (724)

nikodr's picture

27-04-2013, 16:50

Thank you .Well my original idea was psg.but anything could be possible.Why not scc too?the original melodies are really short and efficient on the amount of ram usage.my idea was also targeted towards msx1 and not make it larger than 64kbytes.All we need know is to find the routines and modify thwm.Classical music would be most welcome.I love jazz too.the moonsound or msx music too.
Any programmer here that could tell us wether or not this is easy or hard?

By MäSäXi

Paragon (1884)

MäSäXi's picture

28-04-2013, 09:25

Nice that you also wanted psg. Smile I didn´t mention scc, as I thought psg-only would be closer to original game. But well composed msx-music classical music would be a great idea too, as it´s instruments sound like "real" instruments. Not really, but close enough for a 8 bit computer. Smile I think msx-music may suit well for classical music. Question Not everyone has msx-music cartridge either, though. Unfortunately I have no idea how much more memory msx-music tune may consume, composers can answer this.

An idea, if it can have several tunes, game could have old-skool "Jet Set Willy style Classical Jukebox" to select in-game music. Smile But sure it would be a good idea to not touch original game too much, also just to make it happen, as more things we want to add, more possible it is that it will never see sunlight.

But if it gets finished, it would be great to have this new version made as a new cassette game! And someone could draw a nice colourful loading screen, based on Jet Set Willy II´s imaginative cover art. Or at least use Spectrum´s original loading screen, which is a simplified version of cover art. Why I am wishing for a new loading screen? Anyone who has loaded original (first) Jet Set Willy on MSX, may have liked it´s simple old-skool loading screen, made by DRAW, PAINT and PRINT#1 commands. After that, same persons who has then seen same Jet Set Willy loading on Commodore 64 may have been amazed about quality of well-drawn hi-res loading screen which is a exact copy of cover art. Smile Why I am wishing cassette version then, as MSX is well-known of being (partly) cartridge based computer? Well, just for nostalgic reasons. Smile To keep "old 1980s feel". Smile I can appreciate hi-res picture more by waiting it to load first. Loading of cassette games which have a nice loading screen is always a pleasant thing for me! Smile But for sure, I can appreciate this new version a lot if it doesn´t get any fancy loading screens but "just" new longer tunes, even if it never gets released on cassette (or cartridge) but just as disk image. Smile As we have seen great msx2 versions of several Spectrum´s Ultimate games, I hope we can get this "longer tunes version" of Jet Set Willy II for MSX1. Smile Thank you in advance for any possible efforts for nikodr´s idea. Smile

By Camerone Else

Supporter (8)

Camerone Else's picture

31-10-2013, 04:26

Bear in mind that I'm talking of work I did about 25 years ago, but the main issue I remember was that accessing the video hardware was very slow. In the Spectrum version written by Mathew Smith, he was able to construct the new image in other memory, and then copy it into the screen memory very quickly. That approach wasn't viable on the MSX. The approach I used was partly to make use of hardware sprites, and partly to update only the parts of the screen that were changing. There was a hardware limitation of no more than four sprites on any horizontal line, so what was a sprite, and was was memory update, changed depending on where Willy was.

An odd thing that puzzles me to this day was that when I was working on JSW2, I found that the motion wasn't steady. This effect is visible on the Manic Miner and JSW 1 in emulators, but for whatever reason it wasn't noticeable on the actual hardware - or at least, not the hardware I was using, and Software Projects never said anything. I thought I'd traced the problem to a hardware problem, in that reading the flag that indicated end of screen would occasionally return zero, but apparently also clear it just as it was being set. It seemed an odd fault, and it also appeared to happen with sprite clash detection (which I wasn't using, but tested in the process of trying to diagnose this problem). I eventually worked around it by delibrately having two black overlapping sprites at the bottom right hand corner of the screen (where it's black anyway). Since the sprite clash flag would be set for each clashing pixel, if it got cleared as I read it the first time, it would get set again before I read it again. So that's the method that JSW2 uses to detect end of frame.

The puzzle is the fact that emulators appear to reproduce what I had thought was a hardware fault. It seems very unlikely that they'd do this intentionally. So, after all this time, I can only assume that I had coded the thing wrongly, and that my workaround was actually a workaround for my own error.

I did all the work using an assembler running on a Sinclair Spectrum. Intially, I was just using cassette tape for storage, but later I upgraded to Microdrive, which were a big improvement, except when they jammed, which they did annoyingly often.

By Manuel

Ascended (15457)

Manuel's picture

31-10-2013, 09:34

Camerone Else: fantastic that you share your story here with us! Thanks a lot for that!

Ever thought of adding coloured backgrounds to the JSW/MM games? (If we look at Konami games like Maze of Galious, we know it's possible ;-))

By Camerone Else

Supporter (8)

Camerone Else's picture

31-10-2013, 10:01

The Spectrum divided the screen into 8 x 8 pixel blocks, and only two colours could appear in a block. The MSX video system extended that somewhat in that instead of two colours having to apply to the 8 x 8 block, each 8 pixel line in the line could have two colours assigned to them. So it was certainly possible to have more colour than the Spectrum allowed, but it was far from the pixel-by-pixel colour scheme we have these days.

I've a feeling that there was a lower resolution option that allowed more freedom in the use of colour, but using that would necessarily have made the game look rather different.

Anyway, my remit was to replicate the Spectrum games, for which I quoted a fixed price in advance - I was not a Software Projects employee, and was doing the work in Paris. I had no motive to improve the games, beyond the couple (I think it was only two) of extra rooms I put into JSW II (Maze, Transmat Testing Bay), which were there because Software Projects had been slightly taken aback by my quote (no - I won't give details) for JSW II, and asked whether I could extend it for that price, to which I was non-commital, but felt I had to do something. They were really the limit of my original thinking - I am, and was already then, essentially a software engineer, not a creative artist.

By Manuel

Ascended (15457)

Manuel's picture

31-10-2013, 15:23

So, how much time did it take to do the conversion?

By Camerone Else

Supporter (8)

Camerone Else's picture

01-11-2013, 01:38

Now you're asking - after a quarter of a century. Well, I think it was about three months, and we're talking 7 days a week. Although Software Projects may have felt the asking price was a bit high, I can assure you that I earned every penny.

Now - an anecdote - how working on this stuff got me caught up in the arms control laws. I started the conversion on these while I was living in London, and moved to Paris with work in progress. I had a Toshiba MSX machine which belonged to Software Projects, which meant I had to consider the GST implications involved in importing it into France and later back into England. Had I known what would happen, I'd have just told customs it was mine, and left it at that. As it was, I followed the rules, and declared it to customs on leaving the UK. And they impounded it - or at least, wouldn't let me take it with me. The reason? The Z80A microprocessor was classified as a munition as the law then stood, and because I was exporting it on behalf of a company (Software Projects), I needed an export licence for it, which I didn't have. So it stayed behind, and I had to get a family member to travel to Gatwick to retrieve it.

Page 4/5
1 | 2 | 3 | | 5