New version of Centipede for the BBC Micro (in progress)

new games to be launched and discussed here
User avatar
davidb
Posts: 2231
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by davidb » Sun Mar 04, 2018 2:21 pm

Pablos544 wrote:I'm sorry my BBC ROM dyslexia is pretty poor I understood that you could only run * commands on things that were setup to run these commands in (loaded) ROMs? :?
Some disk filing systems let you use star commands as shorthand for loading and running programs with *RUN. So *CENTI would work if CENTI was on a DFS disk, but not if it was on a cassette. I don't know what the underlying mechanism is for this. Perhaps someone will explain it to us. :)

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by crj » Mon Mar 05, 2018 12:43 am

When you type *FOO:
  • BASIC (or whatever) calls OSCLI, passing it the string "FOO"
  • The operating system indirects through the CLIV vector. If anything has intercepted that, it gets dibs on handling the command. But, if you reach the operating system's default handler...
  • Tell the current filing system that a command's being executed. (The only use of this I'm aware of is to expire *ENABLE in DFS.)
  • Strip leading spaces and asterisks, ignore comments (commands that begin with | ), empty commands, overly long commands.
  • If the command begins with a /, pass it directly to the current filing system
  • Handle the command if it's one of the OS's built-in ones.
  • Pass the command to all the ROMs. This is how ROMs implement utility commands, the command to start a language, the command to select a filing system, etc.
  • Pass the command to the current filing system, which handles it as it sees fit.
So what happens if a command makes it all the way to that last step without something claiming it?
  • The tape and ROM filing systems just give a "Bad Command" error
  • DFS and ADFS check for filing-system specific commands such as *ACCESS . Then, if it's not one of those, they behave as though you'd typed *RUN FOO.
  • NFS natively recognises a tiny handful of commands like *I AM and *BYE (is that the lot?). Other commands, it passes to the fileserver, which can implement things like *ACCESS , but also behaves as though you'd typed *RUN FOO if it doesn't recognise the command.
  • ...and so on.

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Mon Mar 05, 2018 7:39 am

What is the correct way to catch an error from OSFILE 0 of &ff when called from asm.
I was expecting the call to return with an invalid file type, but it doesn't come back,it just drops put, back to the basic prompt.
I'm basically trying to do *load and *save without basic. I get the same problem with oscli.

User avatar
EdwardianDuck
Posts: 48
Joined: Thu Aug 10, 2017 8:07 pm
Location: Northamptonshire
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by EdwardianDuck » Mon Mar 05, 2018 9:49 am

Based on advice from others here, you'll need to temporarily redirect BRKV to your own error handler, then restore it later.

Here is an example from my code. Unfortunately this depends heavily on MADS syntax and my own (slightly wobbly) macros.

Code: Select all

				.proc SaveFile (.word FileName .dword StartAddress, StopAddress) .var
					FileName = _FileIO.SaveFile.FileName
					LoadAddress = _FileIO.SaveFile.LoadAddress
					ExecAddress = _FileIO.SaveFile.ExecAddress
					StartAddress = _FileIO.SaveFile.StartAddress
					StopAddress = _FileIO.SaveFile.StopAddress
					OK = _FileIO.SaveFile.OK
					mva #1 OK
					lda #0
					ldx #.lo(FileName)
					ldy #.hi(FileName)
					TRY
						jsr OSFILE
					CATCH
						dec OK
					FINALLY
					lda OK
					rts
				.endp
And here are TRY CATCH FINALLY macros (excluding all the macro stack handling stuff).

Code: Select all

; Crude approximation of TRY...CATCH...FINALLY. Note that this ONLY works if the last statement of the TRY block is a JSR.
; Note that all three macros preserve X. If you remove that, stuff breaks.

			.macro TRY
				.def :?_TryCount = :?_TryCount + 1
				_PushStack "TRYSTACK", :?_TrySP, :?_TryCount
				.var .byte _XSave
				.var .byte _StackSave
				stx _XSave
				tsx
				stx _StackSave
				_OpCodeLabelImmediate "MWX", "CATCH", :?_TryCount, BRKV
				ldx _XSave
			.endm 
			
			.macro CATCH
				_GetStack "TRYSTACK", :?_TrySP, ?n
				_OpCodeLabel "JRA", "FINALLY", ?n
				_SetLabel "CATCH", ?n, *
				stx _XSave
				ldx _StackSave
				dex
				dex
				txs						
				ldx _XSave
			.endm

			.macro FINALLY
				_PopStack "TRYSTACK", :?_TrySP, ?n
				_SetLabel "FINALLY", ?n, *
				stx _XSave
				mwx Environment.SystemBRKV BRKV
				ldx _XSave
			.endm
Below is a rolled out (and tested) version which should be easier to adapt for another assembler (BeebAsm if I remember correctly).

Code: Select all

				.proc SaveFile (.word FileName .dword StartAddress, StopAddress) .var
					FileName = _FileIO.SaveFile.FileName
					LoadAddress = _FileIO.SaveFile.LoadAddress
					ExecAddress = _FileIO.SaveFile.ExecAddress
					StartAddress = _FileIO.SaveFile.StartAddress
					StopAddress = _FileIO.SaveFile.StopAddress
					.var .byte _XSave
					.var .byte _StackSave
					OK = _FileIO.SaveFile.OK
					mva #1 OK
					lda #0
					ldx #.lo(FileName)
					ldy #.hi(FileName)
;					TRY
					stx _XSave
					tsx
					stx _StackSave
;					_OpCodeLabelImmediate "MWX", "CATCH", :?_TryCount, BRKV
					mwx #Catch1 BRKV
					ldx _XSave
;
						jsr OSFILE
;					CATCH
;					_OpCodeLabel "JRA", "FINALLY", ?n
					jmp Finally1
;					_SetLabel "CATCH", ?n, *
Catch1:
					stx _XSave
					ldx _StackSave
					dex
					dex
					txs						
					ldx _XSave
;
					dec OK
;					FINALLY
;				_SetLabel "FINALLY", ?n, *
Finally1:
					stx _XSave
					mwx Environment.SystemBRKV BRKV
					ldx _XSave;
					lda OK
					rts
				.endp	
The idea is that OK contains #1 if no error thrown, or #0 if there was an error.

Hopefully this make some sort of sense. One caveat, the statement immediately prior to the CATCH macro MUST be a JSR to the routine which might issue a break instruction.

I'm using this in my Sudoku solver. If you enter an invalid filename, the error is caught and the MOS error message echoed and control returns to the program.

Jeremy
Master 128 + RetroClinic DataCentre + Internal Pi Zero Coprocessor, MiST

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Mon Mar 05, 2018 12:44 pm

Thanks, that sounds like what I tried. I'll take a look at your code and try to see where I went wrong.

User avatar
kieranhj
Posts: 726
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by kieranhj » Mon Mar 05, 2018 12:57 pm

Yes, as Jeremy says you’ll need your own BRKV handler. When the OS or DFS issues an error it dumps the error number and error string at the bottom of the stack page &100 and calls BRK.

The challenge is that the stack might well be busted so safest if you can reset SP to &FF and jmp to a known restart function in your code.

For POP I have my own BRKV handler for when I’m attempting to load or save the savegame data, as the disc might be write protect, full, file locked or missing etc. I only call the OSFILE fns from a known point (at the start of the main loop) and flag that a FS operation is taking place. If the BRK handler is entered with the “FS call” flag set then the game recovers by re-entering the main loop in a good state. Otherwise the game reboots to the attract.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

Michael Brown
Posts: 2034
Joined: Sat Apr 03, 2010 12:54 pm
Location: Nottingham
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Michael Brown » Mon Mar 05, 2018 5:20 pm

Hi Tricky
This looks fantastic.
Thanks for the lives!

Any chance of being able to press BREAK to exit.
I believe moving code down and over &258 causes the problem.

regards,
Mick.

crj
Posts: 834
Joined: Thu May 02, 2013 4:58 pm
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by crj » Mon Mar 05, 2018 5:36 pm

kieranhj wrote:Yes, as Jeremy says you’ll need your own BRKV handler. When the OS or DFS issues an error it dumps the error number and error string at the bottom of the stack page &100 and calls BRK.

The challenge is that the stack might well be busted so safest if you can reset SP to &FF and jmp to a known restart function in your code.
Mmm. I've always got the impression the CPU stack is no place for important data when a BRK occurs on an Acorn machine. )-8

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Mon Mar 05, 2018 7:31 pm

EdwardianDuck wrote:...Below is a rolled out (and tested) version...
Thanks, that confirmed that I was on the right path, but I shouldn't have skim read the AUG!
16.2 OSFILE Read or write a whole file or its attributes

Call address &FFCE Indirected through &212
Note: the correct address seems to be &FFDD
It does feel like a very awkward way handle errors and an even worse place (as you say) to put the error message (DFS's choice).

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Mon Mar 05, 2018 8:02 pm

Just in case anyone wants a tape version, see attached .zip!

I have added basic hi-score loading and saving, you just can't see them.
When you start the game with *RUN GAME it will clear the screen and display "Searching", just press escape to start the game.
If you have been playing it and load it again, it will try to save the hi-scores, if you allow it, it will then quit!
A quicker way to save is *SAVE CENTI-HI 111 +62 and to stop if from saving ?&111=0.

All this makes much more sense from disc (MMC, emulated or real).
SHIFT-BREAK to boot the game (will use default hi-scores if there is no CENTI-HI file).
CTRL-BREAK and then SHIFT-BREAK again and it will save CENTI-HI and then quit.
I know this is quite clumsy, but after I have stomped over everything, I can't think of a better way to do it.
Attachments
Centipede.zip
(8.2 KiB) Downloaded 26 times

User avatar
Pablos544
Posts: 332
Joined: Tue Jul 15, 2014 4:25 pm
Location: London, UK
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Pablos544 » Tue Mar 06, 2018 1:15 pm

crj wrote:DFS and ADFS check for filing-system specific commands such as *ACCESS . Then, if it's not one of those, they behave as though you'd typed *RUN FOO.
NFS natively recognises a tiny handful of commands like *I AM and *BYE (is that the lot?). Other commands, it passes to the fileserver, which can implement things like *ACCESS , but also behaves as though you'd typed *RUN FOO if it doesn't recognise the command.
...and so on.
=D> =D> =D> =D> =D>

[EDIT] so it maybe that the underlyding Filing System may try to give you a bit of a break to see if you really meant *RUN FOO before finally giving up on it? Ingenious. Thanks, crj :D

User avatar
Pablos544
Posts: 332
Joined: Tue Jul 15, 2014 4:25 pm
Location: London, UK
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Pablos544 » Tue Mar 06, 2018 1:29 pm

davidb wrote:Some disk filing systems let you use star commands as shorthand for loading and running programs with *RUN. So *CENTI would work if CENTI was on a DFS disk, but not if it was on a cassette. I don't know what the underlying mechanism is for this. Perhaps someone will explain it to us. :)
Cheers, davidb. Looks like our prayers have been answered :lol: :oops:

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Wed Mar 07, 2018 7:18 pm

Michael Brown wrote:Hi Tricky,

Fantastic!

Is there any chance of you doing a splash screen?
Also I hope you can include at least a "Game Over"

regards,
Mick.

PS Keep up the good work!
I will add a splash screen later, and it looks like I can shuffle things to free up the BREAK control byte, so that might be OK too (if not its CTRL-BREAK as usual!).

Is this OK for "Game Over" - sorry, no lower case ;) - I must check what in my hi-score code is corrupting the score :oops:
Attachments
GameOver.png
GameOver.png (2.83 KiB) Viewed 1414 times

Michael Brown
Posts: 2034
Joined: Sat Apr 03, 2010 12:54 pm
Location: Nottingham
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Michael Brown » Thu Mar 29, 2018 5:58 pm

Hi Tricky

Fantastic!

regards,
Mick.

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Thu Mar 29, 2018 9:52 pm

Thanks Mick,
hopefully I will get the final tweaks done this weekend and maybe add some instructions!

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Thu Apr 05, 2018 10:00 pm

I've added music.
Escape will quit cleanly (hopefully).
I filled in the high-score competition results plus one playtester.
The bug where the centipede is turning to go up immediately above you and it kills you is still there.
I confess, I caused it by a short-cut I took when writing the animation system and it is proving tricky to fix properly, hence RC1.
Any issues, please let me know and I'll try and sort them.
I am still working on fixing the bug, but it would be reassuring to know that I haven't broken anything else in the meantime!
You should still be able to use the CENTIPEDE "exe" as a ROM, which should boot automatically if in slot 0 (master cart).
Richard
Attachments
CentipedeRC1.zip
(9.68 KiB) Downloaded 27 times


User avatar
Dethmunk
Posts: 189
Joined: Fri Jul 01, 2016 12:29 pm
Location: Guildford
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Dethmunk » Tue Apr 17, 2018 9:36 pm

=D> Are you going to do an Beebcade (Arcade Compilation) Like a MAME frontend. So you can launch to the different ports you've done. You must have a fair few now.
Look awesome as always Tricky. Nice work.

John.
Image

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Tue Apr 17, 2018 10:17 pm

I use a mode7 double height text menu for the shows I do with my games and an option for the STH archive.
There was some talk at one point of a retro software release, but as they are not licensed, I doubt that will happen.
Did you notice that I added your splash screen to phoenix?

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Tue May 01, 2018 7:42 pm

I hope I have now fixed the unfair death if you are immediately below a segment, just as it is about to reverse and go up.
I have also added preliminary Trackball support for the STACK trackball (thanks Arcadian), it should also work in "analogue mouse stick" mode in emulators. Your avatar is a little jittery on real hardware, but I don't think the STACK trackballs are the best solution and haven't put the time in to remove the jitter.
I don't have any working hardware to hand, so I might just have broken everything, hope not.
The game should work with joystick or keyboard on B, B+, Master and Compact (no trackball).
I think this is the final version, unless someone find a bug.
Enjoy.
Do you think that it is ready for bbcmicro.co.uk?
Attachments
CentipedeRC2.zip
(10.54 KiB) Downloaded 18 times

User avatar
leenew
Posts: 3690
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by leenew » Tue May 01, 2018 8:51 pm

I will stick this version up tomorrow, and if any bugs are reported it's easy enough to keep updating the image :D

Lee.


Michael Brown
Posts: 2034
Joined: Sat Apr 03, 2010 12:54 pm
Location: Nottingham
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by Michael Brown » Wed May 02, 2018 7:15 am

Fantastic Tricky!

Just one thing, there seems to be several spelling errors in your instructions.

'around' , 'drops' and 'poisons' are the ones I think need changing.

again, great work.

Mick.

User avatar
leenew
Posts: 3690
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by leenew » Wed May 02, 2018 7:29 am

Please check all details are correct!
http://bbcmicro.co.uk/index.php?rt_R=&r ... =on&sort=u

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Wed May 02, 2018 4:43 pm

I'll have a look, I could try and blame it on writing them in a hex editor, but I also can't spell ;)

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Wed May 02, 2018 5:13 pm

Spellings hopefully corrected.
Attachments
CentipedeRC3.zip
(10.54 KiB) Downloaded 20 times

User avatar
leenew
Posts: 3690
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by leenew » Fri May 04, 2018 8:45 am

Hi Tricky, I don't want to be a pain :wink: but in the first paragraph, the bit that reads "a mushroom will grow, these can also be shot..." would read better if it said "a mushroom will grow. These can also be shot...".
In other words, change the comma to a full stop and make the small 't' a capital 'T'

8-[

Lee.

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Fri May 04, 2018 12:01 pm

That is exactly what the misses said 10 seconds after I posted that image.
I'll change it.
Note to self, next time don't bother with instructions ;)

User avatar
leenew
Posts: 3690
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by leenew » Fri May 04, 2018 1:43 pm

Ha Ha!
Mick Brown and me have been proofreading game instructions for the last year so things like that really stand out :lol:
In future, if you want to post rough instructions, we could tidy them up to make sure they read OK.
My spelling ain't too bad, but then again, my coding skills are shockingly bad :wink:

Lee.

User avatar
tricky
Posts: 2847
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: New version of Centipede for the BBC Micro (in progress)

Post by tricky » Fri May 04, 2018 4:57 pm

. These
Attachments
CentipedeRC4.zip
(10.54 KiB) Downloaded 18 times

Post Reply