Crap 0.1 first assembly project

Show us what you're working on, (preferably with screenshots).
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Crap 0.1 first assembly project

Post by Ast A. Moore »

Nomad wrote: Thu Mar 15, 2018 12:10 pm This was a combination of machine code + basic. Not as claimed in the magazine reviews as 'just a program written in BASIC'. Had they looked at the source they would have seen that on the first few lines you have a machine code portion (to load the map.)

Code: Select all

60 POKE 23658,0
70 LET A=A+1
75 IF A<58603 THEN GO TO 60
80 DATA 33,0,64,17,238,228,1,0,27,237,176,201,33,238,228,17,0,64,1,0,27,237,176,201
90 RANDOMIZE USR 58580
Just a BASIC game eh... facepalm...
To be fair, these are just two harmless snippets of machine code. One copies the screen to another memory location, the other copies it from that location back.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

True but it shows that the program was not just written in basic. :lol: Ok I am being pedantic but still.

It clocks in at 401 lines of basic, with a sprinkling of machine code and pokes.

It's begging for a make over. But then that kind of makes sense it was a very early program judging by the style. Having reviewed the code. I wonder why the author didn't do the input routine & screen update in machine code. It would have made a huge difference... Hmmm... mysterious.
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF »

I bet he got those screen copy routines from somebody else, and used them without knowing assembly.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Crap 0.1 first assembly project

Post by Ast A. Moore »

Seven.FFF wrote: Thu Mar 15, 2018 1:41 pm I bet he got those screen copy routines from somebody else, and used them without knowing assembly.
Heh. Possibly. Then again, those are just LDIRs, preceded by setting up the HL, DE, and BC register pairs. It’s also possible he set out to write the whole thing in BASIC, realized some aspects were painfully slow, and sped them up with morsels of machine code.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

I get the feeling if he knew machine code he would have done all the INK, PAPER, BORDER stuff with pokes, even if it was a BASIC program.

But if he was getting help you would have thought they would have done the input routine - but I can kind of see why they didn't if they were pushed for time and especially if it was not the author who was doing the assembly.

There again, this was 1982 so.. hmmm.
Last edited by Nomad on Thu Mar 15, 2018 2:37 pm, edited 1 time in total.
User avatar
R-Tape
Site Admin
Posts: 6397
Joined: Thu Nov 09, 2017 11:46 am

Re: Crap 0.1 first assembly project

Post by R-Tape »

Ast A. Moore wrote: Thu Mar 15, 2018 2:18 pm morsels of machine code.
Now there's a cracking name for a coding book.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

R-Tape wrote: Thu Mar 15, 2018 2:36 pm
Ast A. Moore wrote: Thu Mar 15, 2018 2:18 pm morsels of machine code.
Now there's a cracking name for a coding book.
Byte in to Spectrum machine code...

Ok I'll get my coat :lol:
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: Crap 0.1 first assembly project

Post by Ast A. Moore »

R-Tape wrote: Thu Mar 15, 2018 2:36 pm
Ast A. Moore wrote: Thu Mar 15, 2018 2:18 pm morsels of machine code.
Now there's a cracking name for a coding book.
Morsels of Machine Code

Chapter 1. BCD: How to Nibble Away at Your Bytes
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

To give some insight to the curious..

What I decided to do was to understand the battle of britan code better was to transcribe it to a legal pad. This gave me time to think about each line and what it did within the program. And try and get a handle on how the guy that wrote the program was thinking. I think its harder when you are just looking at a listing screen.

At the end I finish with hand cramps and 30 pages of legal papers. :lol: What I can say so far is its almost all BASIC code. its structure is really just a stack of if statements comparing various arrays against a few magic numbers. There are random values that plug into a model to handle stuff like movement, damage. And each unit has fule consumption tracked.

The code seems to have been worked on in a number of stages. By the line numbering the guy started by using a skeleton then expanded/edited as he went. Pretty standard stuff. The only weird part is the way that the map code sticks out like a sore thumb. Can't be 100% but it would appear this came from a different source.

The enemy will attack one of three targets. I never really thought about how limiting this is to game play.

There only being one map is also another interesting design decision. It just seems sad that with what would have been a few more months of development this could have been a very nice game.

Anyway enough speculation on what could have been. :lol: The variables are what you would expect from this period - they are sparse but functional. The use of magic numbers is not 100% there was an effort to make the code readable as some program tasks are assigned variables for the line numbers to use in the code. I thought that was quite progressive for 82'.

Next up will be putting this onto +3 disk. Luckily there is no complicated protection scheme to worry about. It's just a matter of copying the screen data, the code onto the disk. (well the memory disk first then the real disk).

After that (assuming I didn't screw it up) I will go through and replace as much as the basic with pokes.) If it makes seance to go further down the rabbit hole and actually start implementing parts of it in machine code then will have a go.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Update:

Well battle of Britain is progressing well...

But talk is cheap perhaps some screen shots. :lol: Still at the rough prototype stage but one of the things that really let this program down was the interface. As I wanted to learn more about vector type graphics I thought this would be a good chance to figure out the assembly draw/plot routines.

At the moment its still a hot mess of basic/assembly. but this was the fastest way to figure out the table values. Next will be get it all generated in assembly, the loop code. This should speed things up.

Really I want to make hexagon tiles but circles are ok at a push I guess... anyway you can see what I am getting at.

The red team (Germans) you always have the data to the right, same as blue team (Brits). With the targets bombed also this takes away the need to call up the data from the input, thus we shorten the input loop giving a much tighter input routine. Given this is one of the programs bottlenecks I think its worth loosing a little bit of screen real estate to this.

My idea is having two maps, the first is wide area, then a local map. One thing that is very realistic is you don't get to micromanage the patrols. This was probably first a limitation of the program but it added to the realism. However it got panned for this in reviews (quite unfairly).

I am hesitant to putting a third screen (battle screen) where it would switch you to pilot view where you could attack the escorts/bombers instead of it being a algo result. This would take away from the realism of being in bomber command. But on the other hand by offering the player the chance to 'switch roles' and take the place of the patrol for encounters it would fix what was according to the reviews a major failing of the game 'its boring you can't fight the enemy yourself..'

I guess its one of those do you sacrifice realism for gameplay kinda deals.

Another thing I often thought was lacking in the game was being able to play the other side. This would enhance the replay factor and you could try some new strategy (instead of targeting civilians - target the airfields.. making Sea lion possible). I often thought this would have made the game 10x better as it got a bit boring because you knew that the red team was always going to attack the civilian targets.

I would need to have a think how to do this but this would just require extension of the enemy targeting (the computer only has 3 possible targets as the red team.. to enable a switch to bombing RAF airfields you open up the targets.. making the game much more difficult as a defender but also much better inmo.)

Image
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Update:

Looking at the combat/mission model. It has a number of problems. The RAF numbers are wrong, You have a maximum of 90 fighters, this should be closer to 630.. Also the number of bases should be increased to 18..

This is not so hard to implement, actually its pretty easy. I don't understand why the wrong data was used in the first place..

The German bases are easy to model - you have N number of bases, once you know how many groups are being sent randomly select the base for each group. This can then be used to determine stuff like fuel level.

The detection chance totally changes the game - to make it more realistic detection should be variable. So you can either have all systems (observer + radar) working perfectly in good weather. So you have advanced warning of attack and can accurately respond. This is the default state in the original game.

If weather is bad, observers can't see the incoming attack until its ontop of them. Radar is still primitive and cannot detect aircraft bellow 1000ft (thus the need for observers), the system also can fail due to weather conditions. Therefore this worst case you have no advance warning.

and a spread in between.. the ultimate impact is enhanced gameplay, sometimes the bombers/escorts just come out of nowhere and you have to scramble. In future defenders would get a penalty (because not enough altitude to effectively engage..) but at the moment I don't want to mess with the combat model.

With this change you switch from a scramble based approach (where you just react to the incoming confirmed enemy positions.. to one of patrol based gameplay - because you can't rely on having advanced information.)

German data needs to be updated, I want to update the targets so RAF Radar can be targeted, the Air bases, Shipping in the Chanel, and civilian population centers. This is also not the most difficult job in the world. its just a matter of plugging in the coordinates of the different locations and randomly selecting a objective.

If just these three things are done (updating RED/BLUE team data, the objectives, and increase the air bases/radar stations) It will really improve the game.

Having you play the RED team and computer the BLUE is more complex.. I want to improve the model first before I do this.

There are a few factors that were never modeled by the game but (really should have been) weather, observer core response, radar.

At first I thought it was a problem with the game size - perhaps too much memory was used already but this is not the case, there is more than enough room to add in all the above...

The combat model is still pretty bad/simplistic. But I don't want to mess with that till I have the underlying data fixed. The program is slow enough as it is with the simple combat algo. If I plug in a better one its going to slow things down even more.
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Image

:lol:
Image

Little things please little minds...
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Update:

So as you can see by the string slicing examples, I have been giving the old coconut a rest from the assembly :lol: There is a point where the best way to move forward is to take a step back and let yourself have a think on whats stopping progress.

:lol: That's what I tell myself anyway - to be honest with all of the application issues it was getting to the point where I was asking myself 'why am I doing this?' :shock: I had hit the assembly burnout phase.

But being a suborn potato I was not about to walk away and admit defeat. No I would do something else that was tangentially useful and come back to it when I was 'ready' :lol: Kind of like an act 2 before the training montage.

Well y'all saw what I did - gathered a huge amount of papers/books on chess & chess computers. This is been a great help and totally changed how I thought about the project. It was one of the best unintentional moves I made.

Other than that - I wanted to quickly prototype ideas I was having not just for the project but just random stuff that would take my interest. I wish I was at a level in specy machine code to do this in assembly but am not. So I settled on its Poor cousins Forth & Basic. Oddly this enabled rapid prototyping and in many cases exposed errors in my judgement/thinking that would have taken much longer for me to figure out had I done it with assembly. Also there is the issue that assembly being so flexible and fast it can mask many logical errors that get exposed pretty quick in slower languages like Forth or Basic.

The thing with BASIC is, yea its slow, yes its somewhat cryptic but I found myself many times just playing with it and having a bunch of fun. Unintentionally productive. I had my own numbers station running all in BASIC using potato techniques that a 'real' programmer would never admit to. :lol:

I then thought to myself 'but I could make this respectable, use a proper for next loop with some sort of string array and its all going to look pretty nice.. The interesting thing about doing the numbers station in basic was - speed was not an issue. As I am just vomiting out numbers in Morse, Basic is good enough to get the job done. There would be no perceptible speed advantage in doing this in assembly.

This lead to another insight - just sometimes it makes sense to use BASIC. :lol:

The corollary being therefore sometimes it might be a good idea to use BASIC & Assembly in a kind of unholy alliance. The more I thought about this and looked back on the documentation this was really how the designers anticipated an 'accomplished' user to use the machine. Not to be doing stuff purely in assembly but to be using a hybrid solution. (well at least in the beginning).

I think that is a somewhat lost skill is figuring out the balance of BASIC/assembly within a program to get the optimal results. I questioned the cost/benifit of implementing projects wholy in assembly - especially when I didn't have a great grasp of z80. There is a big time cost..

I guess what I came to appreciate is that perhaps my various projects could be finished/developed in a better way if I just combined basic & assembly. That way when I hit a brick wall with the assembly solution I could just cheese things with a basic solution to the problem and move on and replace it later. This would seem to be a better approach to what I had been doing.

The other big advantage with being a BASIC bod is there is a ton of books that are actually competently written for the spectrum :lol: the better part of a decade of magazines, plus I had experience from back in the day writing it. So its a lot easier. :lol:

That said I was raring to get back to the esoteric Z80 assembly, the seemingly antagonistic tools and get stuck in. So I think the time away was useful. :lol:
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

MMMMM BASIC..

Image

Image

Image

That last one I can't seem to crush into a 2 line program..

Busy reviewing CCS 2003 :lol:
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

More BASIC silliness.

Image
User avatar
Kweepa
Manic Miner
Posts: 311
Joined: Sat Feb 03, 2018 6:14 pm
Location: Albuquerque, New Mexico

Re: Crap 0.1 first assembly project

Post by Kweepa »

One liner for the coin toss program:
1 DIM a$(2,5): LET a$(2)="inf": LET heads=0: LET tails=0: FOR i=1 TO 2 STEP 0: LET coin=INT (RND*2): LET heads=heads+(coin=0): LET tails=tails+(coin=1): LET a$(1)=STR$ (heads/((tails=0)+tails)): PRINT heads;"/";tails;"=";a$(1+(tails=0)): NEXT i
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Big thank you to Kweepa - tip of the hat to you sir.

Image
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

More Basic sillyness.

Due to a splitting headache I haven't been able to get much work done. Still was enough juice in the tank to mess around with some basic in the downtime.

Code: Select all

   1 DIM C$(10,50): LET C$(1)="HELP ME. I CAN'T GET OUT. YOU HAVE TO HELP": LET 
C$(2)="THE DOOR IS LOCKED. TELL MY FAMILY I LOVE THEM.": LET C$(3)="IT'S SO DARK
 I HAVE NOT EATEN FOR DAYS.": LET C$(4)="I BEEN DRINKING URINE FROM MY SHOE": LE
T C$(5)="YOU CAN'T TAKE HER FROM ME NOW. SHE IS REBORN."
   2 PRINT "PHONE CALL": PRINT AT 18,10;"PRESS ANY KEY": INPUT A$
   5 RANDOMIZE 
   6 LET PP=100: LET K=7: LET P=2: LET B=2: LET C=1
   8 FOR J=1 TO 4 : GO SUB 700: BEEP 0.3,2: BEEP 0.1,2: BEEP 0.3,2: CLS : NEXT J
  10 PRINT C$(C): PAUSE PP
  15 LET R=INT (RND*2): IF R<>1 THEN PRINT "HE IS HERE, IT ENDS.": IF R = 1 THEN
 PRINT "THE LINE IS SILENT."
  20 IF R=0 THEN PAUSE PP: CLS 
  30 IF R=0 THEN GO TO 10
  40 IF R=1 THEN GO SUB 500
  50 IF C=5 THEN GO TO 1000
 500 GO SUB 600: IF R=1 THEN PAUSE PP: CLS : PRINT "*SCREAMS FILL THE LINE*": PA
USE PP: PRINT "*GURGLES*": PAUSE PP: PRINT "*BONES SNAPPING*" : PAUSE PP: LET K=
0: LET P=7: LET B=7: LET C=5: GO SUB 600: RETURN 
 600 BORDER B: PAPER P: INK K: CLS : RETURN 
 700 FLASH 1: PRINT AT 10,5;"THE PHONE RINGS": FLASH 0: PAUSE 1 : RETURN 
1000 CLS : PRINT C$(5): PAUSE PP: CLS : PRINT "FORGET THIS - IT'S BETTER THAT WA
Y. THIS WAS NOT FOR YOU *CLICK*"
1010 STOP 
Essentially I wanted to use the same part of the program to print different strings based upon the value of C. It's not particularly successful and you can see its missing now the part where the phone rings. :lol:

The idea is you have two random numbers generated, one if if the captor is present in the room with the victim. the second is the dialog that the victim can tell you on the phone. - as you can see the second random value is not there yet.. But ya'all can see how it works.

Even very simple structure can lead to interesting game potential for dialog. Really this is very simple. But for something like text adventure its nice way to spice up the room descriptions.

A lot of text adventures have the npcs as static things - they don't move around - me I was a big fan of the Hobbit. Where guys like Gandalf could wonder willy nilly across the land. I figure that is good for these games. I always wanted the room descriptions to be different based upon random events. Eventually I suppose I could expand the locations to enhance the messages.)

I'll put this down to my migrane .. that and my being a potato. :lol:
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF »

Get well soon! I've hardly done any coding for about two weeks, my brain feels like the inside of an overcooked baked potato.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Yup migraines suck. Lucky for me my head was not too pickled :lol: (just my grammar)

Project time was today reviewing Crap games comp, and reading the rather awesome "Cracking the code on the ZX Spectrum".

I'll put it in the book thread but I might as well record it here also for those who would otherwise miss it.

The above book is in my humble opinion the best practical guide to assembly programming on the ZX Spectrum. The author managed to give someone all the tools they would need to start programming, the explanations to why they were doing it, suggestions for other approaches that the reader to think about and research on their own. But its not just simple stuff - the guy covers a lot - but its not a scatter gun approach its all targeted to creating a program.

I can't say enough good things about this book. Even with the archaic hex monitor - its just one chapter out of the book, and it does not affect the rest of the listings. it's not like other books where its crippled by over-reliance on some esoteric custom assembler or its all in hex (yes there are books like that :lol: ).

Gentle reader you might ask yourself (why did all these books spend chapters on hex monitors and stuff nobody ever read (like octal chapters/sections in programming books.. I defy anyone to say they have used octal in anger in a programming project - not you mr Radar becon man! sit down.)
Spoiler
Image
It was a simpler time..

Anyway moving on. Way to much fun with the crap game comp :lol: Where is the time going? Ok I am easy to please I guess but these little games are great I find myself laughing at their antics. It's a great way to brighten up a day.
User avatar
Seven.FFF
Manic Miner
Posts: 744
Joined: Sat Nov 25, 2017 10:50 pm
Location: USA

Re: Crap 0.1 first assembly project

Post by Seven.FFF »

I did CSE Computing in 1984. Apart from the syllabus not requiring you to have touched or even seen a computer, I'm pretty sure octal was on it. And core memory, chain printers, punched cards and tape, etc.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins
User avatar
Guesser
Manic Miner
Posts: 641
Joined: Wed Nov 15, 2017 2:35 pm
Contact:

Re: Crap 0.1 first assembly project

Post by Guesser »

Teletext magazine numbers and unix file system bitmasks are 3 bit numbers, does that count? (No! Ed.)
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

Guesser wrote: Wed Mar 28, 2018 3:28 pm Teletext magazine numbers and unix file system bitmasks are 3 bit numbers, does that count? (No! Ed.)
Tip of the hat to you sir :lol:

That reminds me of a excellent viewdata book I found a while back I will see if I can dig it out...

Lol I remembered the airfield beacon because it was the only octal application I could think of - When I was doing my A-level I was paranoid that it would come up in a question, "Name one application of octal in software" But it never did...
Seven.FFF wrote: Wed Mar 28, 2018 3:22 pm I did CSE Computing in 1984. Apart from the syllabus not requiring you to have touched or even seen a computer, I'm pretty sure octal was on it. And core memory, chain printers, punched cards and tape, etc.
The system charts and most of the systems analysis by the end of the 90s was so out of date, the books still had all of the old symbols in them. But I guess at the time it made a lot of sense because it seemed like everyone who could was cashing in on the year 2000 'certification' scam :lol: so digging through all these crusty old systems was something we all assumed was going to be important 'for years to come' our instructors actually envisaged that we would be spending decades fixing the year 2000 fallout with legacy systems :lol:
User avatar
Guesser
Manic Miner
Posts: 641
Joined: Wed Nov 15, 2017 2:35 pm
Contact:

Re: Crap 0.1 first assembly project

Post by Guesser »

Nomad wrote: Wed Mar 28, 2018 3:41 pm Tip of the hat to you sir :lol:
Tin hat perhaps?

Image


'Ooligans!
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Crap 0.1 first assembly project

Post by Nomad »

:D Very nice! The patients something like that must take is really something.

Here is my most pointless 1 liner yet :lol: adapted from the hard work of John Wilson.

Yes its slow, this is BASIC! :lol:

Image

And the 1 liner Basic/Machine code hybrid.

Image

Orders of magnitude faster. :lol:
Post Reply