In search of...

Discussion, Reviews & High-scores

Moderator: Moderators

DanSolo
Vic 20 Dabbler
Posts: 88
Joined: Sat Apr 21, 2007 5:22 am

Post by DanSolo »

3 bits per tile is a bit of a nightmare to decode though?
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

DanSolo wrote:3 bits per tile is a bit of a nightmare to decode though?
Not if you organise them as 3 bitplanes @ 40 bytes. :)

But that would apply to the single-file version only. With the unexpanded version, I'd simply copy all 90 level files as plain text onto the disc, for ease of implementation.
Richard James
Vic 20 Devotee
Posts: 269
Joined: Mon Feb 04, 2008 6:06 am

Post by Richard James »

Actually you only need 2 bits per tile unless there is not equal number of crates to destination tiles. Then you would need a 1bit deep bitmap that shows where the crates are on the destination tiles. However I find that is an ugly solution since in the origional game there are only 8/90 maps that need this. To work out what map is you then need to put the map number at the start of the 1bit map. Then if you go backwards or forwards map numbers you need to iterate through these map numbers looking for the correct 1bit map. because there is only 8 1bit maps to 90 2bit maps.

Also if you wanted to save more space and are using the origional 90 levels, you can store the change in size of each map in one byte and then you don't need to store always 18*14 tiles. The biggest difference between the max and the least is 9 tiles which can be represented by 4 bits.

I don't know what the saving would be because I would need to start to write a compressor to find out.
Change is inevitable except from a vending machine.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Those are considerations I'd put at the far end of development.

Really, the most important thing is to get a working prototype. And not to look right at the beginning about any conceivable way to save memory. I'd rather reconsider the used data structures, if they only complicate the design, and make the program development more error-prone.

The 3 bit encoding I presented already can be used in the screen display and shows a natural way of looking at the data.

For example, when a box is moved, there are 3 tiles affected, each of them could be a target or not. With the given encoding, I really don't need to think about all 8 combinations while the program redraws these 3 tiles. Also the count N of all boxes on targets can simply be updated with one Boolean expression:

Code: Select all

yy POKEP,(AAND252)+0:REM old position of player - empty
   POKEP+D,(BAND252)+1:REM new position of player
   POKEP+2*D,(CAND252)+2:REM new position of box
   P=P+D
   N=N+((CAND4)-(BAND4))/4
   RETURN
And here's the code for moving the player without pushing a box:

Code: Select all

xx POKEP,(AAND252)+0
   POKEP+D,(BAND252)+1
   P=P+D
   RETURN
The slight redundancy observable here could be avoided by using an extra Boolean variable that enables or disables both redrawing the box, and updating the box-on-target count, and combining these two subroutines into one. Not that it'll really be necessary.

Michael
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

The 3 bit encoding I presented already can be used in the screen display and shows a natural way of looking at the data.
Simply elegant -- me likes! 8)
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

rhurst wrote:Simply elegant -- me likes! 8)
Besides the fact, that in the main loop diagonal movements should be disallowed, only the routine is missing, that converts the level files on-the-fly to screen data, thereby counting targets (-> M), and boxes-on-targets (-> N) and scans the player's start position (-> P). :P

Add to this the title screen, 'congratulations' message for a completed level, and definition of UDG's - I'd use chars 32..38 for this -, and the game is complete. :)

Any volunteers?

Michael
Richard James
Vic 20 Devotee
Posts: 269
Joined: Mon Feb 04, 2008 6:06 am

Post by Richard James »

I am examining the code you have written and am considering putting the rest of the game together. The only thing I don't understand is how to read and write the levels from the disk drive. I never had that when I was a kid, and I only got my uIEC this year.
Change is inevitable except from a vending machine.
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

When I posted my first message here, I wouldn't have thought it would come this far. I am looking forward to the results.
Happy programming !
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Richard James wrote:[...]how to read and write the levels from the disk drive. [...]
I can provide you with all levels as SEQ files within a *.d64 image.

I'd just like to check beforehand, that all levels contain exactly 16 lines of text (even if these are "empty" with only a CR), so you'd only need to handle different line lengths (trailing empty tiles of a line are truncated).

You'd open one of these files with OPEN 2,8,2,N$+",S,R", read single characters with GET#2,A$ - where A$ could become any of those ' ', '#', '$', '.', '*', '@', or CR -, and close the file with CLOSE 2 - and there you go.

Michael
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Mike wrote:I'd [...] check beforehand, that all levels contain exactly 16 lines of text [...]
Surprise! I've just found out, that levels 52, and 89 actually contain 17 lines! :lol:

But the lines remain at 20 tiles maximum length. Well, then I'll format them all to exactly 17 lines ...

Michael
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Here's the result. Enjoy!

Image

Greetings,

Michael

P.S.: The program is created in two steps. First the joystick routine is created:

Code: Select all

10 POKE1,18:POKE2,16:REMZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
11 FORT=0TO38:READA:POKE4114+T,A:NEXT
12 DATA173,31,145,74,74,41,7,170,173,32,145,73,128,41,128,10,125,50,16,8
13 DATA168,173,57,16,40,16,2,169,255,76,145,211,255,19,235,255,255,20,236
Then, from line 11 on, everything is replaced by this:

Code: Select all

11 POKE55,0:POKE56,29:CLR:V=36864:DIMN(7)
12 FORT=0TO55:READA:POKE7424+T,A:NEXT:SYS58648:POKEV+15,8
13 PRINT"{CLR,DOWN,WHT,9 RIGHT}VIC"
14 PRINT
15 PRINT"{RVS ON,RED,SHIFT-£,2 SPACE,YEL,SHIFT-£,SPACE,C=-*,WHT,SPACE,RIGHT}
   {SPACE,GRN,SHIFT-£,SPACE,C=-*,CYN,2 SPACE,C=-*,BLU,SHIFT-£,SPACE,C=-*,PUR}
   {2 SPACE,C=-*}"
16 PRINT"{RVS ON,RED,SPACE,2 RIGHT,YEL,SPACE,RIGHT,SPACE,WHT,SPACE,RIGHT,SPACE}
   {GRN,SPACE,RIGHT,SPACE,CYN,SPACE,RIGHT,SPACE,BLU,SPACE,RIGHT,SPACE,PUR,SPACE}
   {RIGHT,SPACE}"
17 PRINT"{RED,C=-*,RVS ON,C=-*,RIGHT,YEL,SPACE,RIGHT,SPACE,WHT,SPACE,RVS OFF}
   {C=-I,SHIFT-£,RVS ON,GRN,SPACE,RIGHT,SPACE,CYN,SPACE,RVS OFF,C=-I,SHIFT-£}
   {RVS ON,BLU,SPACE,RVS OFF,C=-I,RVS ON,SPACE,PUR,SPACE,RIGHT,SPACE}"
18 PRINT"{RIGHT,RED,C=-*,RVS ON,C=-*,YEL,SPACE,RIGHT,SPACE,WHT,SPACE,C=-I,C=-*}
   {GRN,SPACE,RIGHT,SPACE,CYN,SPACE,C=-I,C=-*,BLU,SPACE,C=-I,SPACE,PUR,SPACE}
   {RIGHT,SPACE}"
19 PRINT"{2 RIGHT,RVS ON,RED,SPACE,YEL,SPACE,RIGHT,SPACE,WHT,SPACE,RIGHT,SPACE}
   {GRN,SPACE,RIGHT,SPACE,CYN,SPACE,RIGHT,SPACE,BLU,SPACE,RIGHT,SPACE,PUR,SPACE}
   {RIGHT,SPACE}"
20 PRINT"{RVS ON,RED,2 SPACE,RVS OFF,SHIFT-£,YEL,C=-*,RVS ON,SPACE,RVS OFF}
   {SHIFT-£,RVS ON,WHT,SPACE,RIGHT,SPACE,GRN,RVS OFF,C=-*,RVS ON,SPACE,RVS OFF}
   {SHIFT-£,RVS ON,CYN,2 SPACE,RVS OFF,SHIFT-£,RVS ON,BLU,SPACE,RIGHT,SPACE,PUR}
   {SPACE,RIGHT,SPACE}"
21 PRINT
22 PRINT"{YEL,3 RIGHT}WRITTEN 2009 BY"
23 PRINT
24 PRINT"{WHT,3 RIGHT}MICHAEL KIRCHER"
25 PRINT:PRINT
26 PRINT"{CYN,3 RIGHT}ORIGINAL LEVELS"
27 PRINT"{5 RIGHT}(C) 1982 BY"
28 PRINT"{RIGHT}HIROYUKI IMABAYASHI"
29 PRINT:PRINT
30 INPUT"{WHT,2 RIGHT}STARTING LEVEL";A$:LV=INT(VAL(A$)):IFLV<1ORLV>90THEN13
31 POKEV+0,PEEK(60900)+2:POKEV+1,PEEK(60901)+12:POKEV+2,148
32 POKEV+3,34:POKEV+5,255:POKEV+14,5:POKEV+15,110:PRINT"{CLR}"
33 OPEN2,8,2,"SCREEN."+MID$(STR$(LV),2)+",S,R"
34 M=0:N=0:FORAD=7680TO8000STEP20:X=0
35 GET#2,A$
36 IFA$=" "THENA=0
37 IFA$="@"THENA=1:P=AD+X
38 IFA$="$"THENA=2
39 IFA$="#"THENA=3
40 IFA$="."THENA=4:M=M+1
41 IFA$="*"THENA=6:M=M+1:N=N+1
42 IFA$<>CHR$(10)THENPOKEAD+X,32+A:X=X+1:GOTO35
43 NEXT:CLOSE2:POKE37154,127
44 D=USR(0):GETA$:IFA$<>""THEN31
45 IFD=0ORABS(ABS(D)-20)=1THEN44
46 A=PEEK(P):B=PEEK(P+D):C=PEEK(P+D+D):IF(BAND3)=0THENPOKEV+12,240:GOSUB52
47 IF(BAND3)=2AND(CAND3)=0THENPOKEV+13,240:GOSUB51
48 FORT=1TO70:NEXT:POKEV+12,0:POKEV+13,0
49 FORT=1TO30:NEXT:IFN<MTHEN44
50 POKE37154,255:GOTO53
51 N=N+((CAND4)-(BAND4))/4:POKEP+D+D,(CAND4)+34
52 POKEP+D,(BAND4)+33:POKEP,(AAND4)+32:P=P+D:RETURN
53 READA:POKEV+12,A:FORT=1TO150:NEXT:IFA<>0THEN53
54 LV=LV+1:IFLV<91THENRESTORE:FORT=1TO56:READA:NEXT:GOTO31
55 :
56 DATA 0,0,0,0,0,0,0,0
57 DATA 0,24,24,126,24,36,102,0
58 DATA 0,60,66,66,66,66,60,0
59 DATA 221,221,0,119,119,119,0,221
60 DATA 34,17,136,68,34,17,136,68
61 DATA 0,24,24,126,24,36,102,0
62 DATA 0,60,126,126,126,126,60,0
63 :
64 DATA 191,207,217,223,223,217,223,223,223,0
65 :
66 DATA 0,212,217,183,191,198,201,207
67 :
68 P$="CDE@G@GG@AG@E@CC@DE@E@D@C@DDDDD@"
69 P$=P$+"CDE@G@GG@AG@E@CC@DE@E@D@D@CCCCCC"
70 P$=P$+"@@FFF@FFF@A@AAA@A@GGG@E@C@DDDDD@"
71 P$=P$+"CDE@G@GG@AG@E@CC@DE@E@D@D@CCCCC@"
72 FORT=0TO1000:NEXT
73 FORT=0TO7:READN(T):NEXT:SYS58648:POKEV+5,242:POKEV+14,5:POKEV+15,127
74 PRINT"{CLR,6 DOWN,BLK,3 SPACE,SHIFT-C}ONGRATULATIONS!"
75 PRINT"{DOWN,SHIFT-Y}OU COMPLETED {SHIFT-S}OKOBAN!"
76 PRINT"{3 DOWN,2 SPACE,SHIFT-T}HE CHALLENGE WILL"
77 PRINT"{DOWN,5 SPACE}CONTINUE ..."
78 FORT=1TO128:POKEV+12,N(ASC(MID$(P$,T,1))-64):FORS=1TO150:NEXT:NEXT
79 POKEV+12,0:POKEV+14,0
80 FORT=1TO3000:NEXT:RUN
Edit: please note there exists a re-release with a few subtle program changes ... ;) ... and an added boot loader. The listing here is the original version, but the download link has been updated.
Last edited by Mike on Thu Feb 20, 2014 4:12 pm, edited 2 times in total.
wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Thanks Mike

Post by wimoos »

..for putting it together, and that in so little time!

I've tried it out in VICE and it works great. Still a lot of things to do of course, like keeping scores, undo moves, and other intelligent things.

Havent tried it on a real vic, because I haven't got a joystick on it. But don't worry, I reroute input to the keyboard and we're happy.

Cheers.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

wimoos wrote:Thanks Mike ... for putting it together, and that in so little time!
Yes, indeed. It took 2 1/2 hours yesterday evening. 8)

Richard seemed to have lost interest in pursuing the project, so I decided to do it myselves.
I've tried it out in VICE and it works great. Still a lot of things to do of course, like keeping scores, undo moves, and other intelligent things.
Undo of moves is fairly easy to implement. You just need to store the addresses, and directions of the last pushes. With as many slots as you feel sensible.

Scores of course should count moves, and pushes.

Other intelligent things, hmm. One Sokoban implementation I had on an Acorn Archimedes could move boxes from one place to another, automatically generating all necessary moves. The only restriction was, that only that box was allowed to be pushed, the algorithm wouldn't touch (and move out of the way, for example) other boxes.
Havent tried it on a real vic, because I haven't got a joystick on it. But don't worry, I reroute input to the keyboard and we're happy.
Have fun with modding the program. ;)

Michael
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: I can't find your game.

Post by Mike »

stycer wrote:Where can i get a copy of your game?
The windows live site won't let me D/l it
Mike wrote:Name: Sokoban
Author: Hiroyuki Imabayashi
Conversion to VIC-20 by Michael Kircher
Released: August 8th, 2009
Requirements: unexpanded VIC-20, joystick, disk drive

Screenshot:

Download: Disk

Discuss this game here.
gklinger wrote:
stycer wrote:Where can i get a copy of your game?
The windows live site won't let me D/l it
Are you sure? I had no problem downloading it from here. Let me know if you still can't download it and I'll email it to you.

(Perhaps this thread should be moved/merged?)
You should check, whether your ISP and/or the settings in your web browser forbid the download. Another forum member has had a similar problem once.

I've put no restrictions on the download, and it's also not necessary to subscribe to Windows Live.

Michael
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Re: In search of...

Post by adric22 »

wimoos wrote: - Lemmings

(or is this too much too ask for a VIC)
Hmmm.. Actually, I'd already thought about Lemmings for the VIC-20 just the other day. (before I saw this thread) But I think there are two problems with the idea:

1) Graphics resolution. With the C64 version you can barely make out what the lemmings are. The Amiga version runs in 640x200 (if I remember correctly) and the MS-DOS version runs in 640x480. Now we're talking about squeezing them down to 88x184 if you want color, or 176x184 if you don't mind monochrome graphics.

2) Memory.. Although the game code itself could probably fit in 8K, the lemmings "maps" are pretty big. The are usually many times wider than the physical screen and they contain hi-res bit-mapped graphics. I mean, they have to in order to allow for the lemmings to modify it by digging, building bridges, etc.. Even with full 32K of RAM, I just can't see the VIC handling it without major concessions in the way the maps work (such as keeping the entire map the size of the screen and loading each one from disk)

I wouldn't want to go as far as to say its impossible.. but it sure doesn't seem like a good candidate for the VIC-20.
Post Reply