Lady Bug

developing/porting a new game or gaming framework? post in here!
Post Reply
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Lady Bug

Post by lovebug »


28/03/2024 - Latest Build 003392 click here
I really want to try and write universal's lady bug arcade game from 1981 for the bbc model b

This will be the first "real" game I've ever programmed and I haven't done any bbc programming for 30 years so its gonna start slowly while I learn every thing i have forgotten

The original game was z80 based with 24k of program code and i think 8k of graphics

I've worked out that the minimum screen resolution I can get away with and still keep enough detail will be 144*216 pixels (72 * 27 lines) in mode 2

Leaving space from &0300 to &433f (16448 bytes) for program/graphics/sound, gonna be a tight squeeze and i might have to find a way to reduce the storage needed for the graphics

Got to do some more tests see if its possible

The original arcade game
Last edited by lovebug on Mon May 06, 2024 11:47 am, edited 47 times in total.
Image Image Image Image
User avatar
Arcadian
Site Admin
Posts: 4223
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Lady Bug

Post by Arcadian »

Ooh cool, always good to see more Arcade Games converted for the Beeb. Good luck!

I've never really played it, but I think Chrysalis is a conversion of the same game, right?
Please subscribe to the ABug YouTube channel!
User avatar
Kecske Bak
Posts: 752
Joined: Wed Jul 13, 2005 8:03 am
Location: Mélykút, Hungary
Contact:

Re: Lady Bug

Post by Kecske Bak »

Good choice; I'd love to see a faithful conversion of Lady Bug. My favourite version is Bumble Bee, although it's a little bit different to the original. It's one of the most addictive of the old MicroPower titles.
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

thanks guys

I just checked out both games they are quite a bit different to the arcade game

im going try to get as close as possible to the arcade experience as I can, my goals are

50 fps flicker free sprites (theres only 5 sprites on screen at once, im gonna have some fun chasing the beam lol)

music and sound effects from the original arcade game
the original arcade game had two 76489 chips so i'll have to do some priority check for overlapping sounds
as the beeb only has one 76489 but on the plus side it should sound accurate

graphics as close to possible as the original within the limitations of the beeb resolution and color (i'll try my best)

game play to match the original as far as possible
except for one thing, collecting the special bonus in the arcade gives you an extra credit
for the beeb version i'll probably replace the special coin screen with a timed bonus level to collect as many vegetables as possible for points
Last edited by lovebug on Thu Feb 18, 2021 9:39 pm, edited 1 time in total.
Image Image Image Image
User avatar
leenew
Posts: 4900
Joined: Wed Jul 04, 2012 4:27 pm
Location: Doncaster, Yorkshire
Contact:

Re: Lady Bug

Post by leenew »

Not everybody is aware that if you search bbcmicro.co.uk for "Lady Bug", you get some results: http://bbcmicro.co.uk/index.php?rt_R=&r ... =on&sort=u

I tagged "similar" games with their original arcade equivalent 8)
Lee
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

wow eggsman in 10 lines of basic !
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ive just made a font in the style of lady bug im just wondering how to convert it to binary so I can include it into my code, would be nice to see some text on the screen if nothing else :D the font will be double width on the beebs mode 2 wide pixels
ladybug-font.png
ladybug-font.png (400 Bytes) Viewed 15350 times
im working on converting the background tiles and sprites

ive gotta work out in which format im going to store all this data which is hard because I havent written a text or sprite routine yet

right im off to write a text printing routine, i'll be back
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

well I decided to store the font as 1 bit per pixel in 2 bit pairs, 4 pairs per byte stored in top to bottom left to right order, 5 bytes (4.5) to store the 6x6 pixel chr with a maximum of 52 chrs fitting in a 256 page.

the code expands the bit pairs into 2 x 4 bit mode 2 color 15 pixels then uses a single byte as a bitmask to allowing the text to be displayed in color

I knew it would be cpu heavy to decode this format but wasnt too bothered because theres very little text printed during game play (score and collected letters) and I can work around that, the main text is drawn on attract screens or just before the live game screen so no issues there

what I wasnt expecting is the code to take 1142 cpu clock cycles per character ! thats just insane

I wont bother to post any code yet this is way too early , well I will if someone really wants it
Image Image Image Image
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Sorry, this turned into an essay, bordering on instruction.
Please think of it as some food for thought and most importantly enjoy writing your game :)

I looked at Lady Bug a couple of years ago and thought maybe one day, but I don't think that I will get around to it for years if at all.
You may have noticed that I like MODE 1 so as to get the original graphics in, although often with compromised colours.
With MODE 1, you need four copies of the graphics, but can move at one pixel per frame like most arcade originals, rather than effectively two pixels at 25 FPS for MODE 2 (at least horizontally anyway).
I've just trimmed my mockup down to 176x200, about 8.5KB which is quite cramped.
mockup.png
mockup.png (4.55 KiB) Viewed 15248 times
I try to do my games so that the font only needs digits and leave any text to the loading screen ;)
I haven't played lady bug since the 80s and didn't play it much then, so don't remember much of the gameplay.
Magenta would be swapped for the main colour of the enemy type each round and white could probably swap for yellow or cyan on some levels.
I would palette swap at the top and bottom edge of the play area, using the bottom to start drawing.
My Pacman also has five sprites and they draw from the bottom of the maze to the top.
PacMan is ORed on and masked off, the ghosts are just masked on, with a one pixel border so that they self erase.
screenshort.png
screenshort.png (7.47 KiB) Viewed 15248 times
PacMan has 11 character rows to draw, while Lady Bug will have 17, so there should be time for the larger sprites and gates.
In my mockup, the dots are on the corner of four characters (same as PacMan), but the whole area could be moved over and down a pixel to draw them in three adjacent bytes instead of four bytes, one in each character.
I also keep a recently erased ghosts list of dots that have to be redrawn once the ghost has passed over them and unless you EOR everything, you will probably need the same.

I keep the screen 256 wide to keep the maths in the sprite routines quicker, but it probably doesn't matter that much as I setup most of the self modifying drawing code while doing the game logic in the middle of the screen. I guess you could put the bits from top and bottom on the side so as not to waste as much memory; 11KB vs 8.5KB.
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

great tips there tricky thanks

i had thought about using mode 1 but thought it would be too limited but after seeing the original graphics in your mockup im at a crossroads

my main concern for mode 1 was the letters that you collect as these change color during game play, I could keep them in 1 color and use palette swap but then everything on screen changes or have 3 copies in the 3 colors and redraw them

I'll do some mockups myself, i need to think about this

i've not used a beeb for 30 years and just these last couple of days its all coming back to me and im enjoying it a lot so what ever happens its all good :D
Last edited by lovebug on Fri Feb 19, 2021 10:38 pm, edited 1 time in total.
Image Image Image Image
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

For Pac Man I kept different copies of the ghosts for speed of drawing, but for something that isn't drawn every frame, you can store it as colour 3, then AND #&0F for colour 1 and AND #&F0 for colour 2.
It's practically the same code for MODE 1 or MODE 2, just need to have four or two copies and move one pixel per frame or two every other frame.
Sometimes the extra colours are worth it and sometimes the smooth movement is what makes it look like a real arcade game. Either way, vertical movement can be 1 pixel per frame.
I have a pinball game planned and if I get around to it, it will be the same code, but the gfx can be MODE 0, 1 or 2.
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ive played all your game ports are they are top notch, amazing work

I havent writen the sprite routine yet but thats coming next so i'll get an idea if its smooth enough in mode 2

ive been doing some calculations and i think im gonna run out of memory for storing the graphics so might have to use a bank of sideways ram :( , do you have any tips for detecting where/if the ram is available ?

thanks
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

as far as checking for available sideways ram would this be ok ?

select each of the sideways slots in turn

if &8000 or &8003 contains &4c then skip it (already in use)

write some values and verify them and if passes then ram is available for use


I want to do this right and not screw up something someone already has installed into sideways ram
Image Image Image Image
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Not screwing it up isn't straight forward as there are several different types.
There are a few gotchas, writing and reading back a bank that is not connected will often give you back whatever was on the bus.
There are several different ways to enable write access to a bank, eg the Watford 12 ROM board can only be written to by ROMs on the board, so not fram ASM, but can just be *LOADed and it just works, no selection.
My Astro Blaster has a couple of routines for finding SWRAM (and Watford Shadow RAM) and then copying RAM to it.
The older Solidisk modules connect to the user port, so accessing them will probably make the next MMC command fail. I handle this by having an ONERROR to retry the next operation. After the one failure, it should be fine again.
Astro Blaster also only keeps one copy of each of the frames of animation of all the aliens and then expands them to generate the four copies at the start of each wave.
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

From Astro Blaster:
It tries to write 16 unique values (not currently in SWRAM and not going to be written) into SWRAM and then looks for slots that contain the number that they are supposed to before trying to restore the original values.

Code: Select all

.find_swr
  SEI
  LDA &FE60 : PHA : LDA &FE62 : PHA
  LDY #15      
  STY &FE62    
  TYA          
.next_val:     
  LDX #15      
  ADC #1       
.next_slot:
  STX &FE30
  CMP &8008    
  BEQ next_val
  CMP &80,X    
  BEQ next_val
  DEX
  BPL next_slot
  STA &80,Y
  LDX &8008
  STX &70,Y    
  DEY
  BPL next_val
  LDX #0     
.swap:
  STX &FE60  
  STX &FE32  
  STX &FE30  
  STA &FF30,X
  LDA &80,X
  STA &8008 
  INX        
  CPX #16
  BNE swap
  LDY #16    
  LDX #15
.tst_restore:
  STX &FE30
  LDA &8008
  CMP &80,X  
  BNE not_swr
  STX &FE60  
  STX &FE32  
  STX &FE30  
  STA &FF30,X
  LDA &70,X
  STA &8008
  DEY
  STX &70,Y
.not_swr:
  DEX
  BPL tst_restore
  STY &70     \ slot
  LDA &F4
  STA &FE30   \ restore original ROM
  PLA : STA &FE62 : PLA : STA &FE60
  CLI
  RTS
?&70=the first slot or SWRAM's index, 16=No SWRAM.
If ?&70=14, then ?&7E would contain the first bank index and ?&7F the second index.
It doesn't try to avoid banks that have valid data, but that should be fairly simple to add.

To load into SWRAM, first it loads in to main RAM

Code: Select all

  320 ON ERROR GOTO 330
  330 *L.ASTROsp 3000
  340 ON ERROR OFF
  350 ?&7A=&FF
  360 ?&70=?&7F : ?&71=&23 : ?&73=&30 : ?&75=&80 : CALL copy
The copy is really just part of the find code:

Code: Select all

.copy
  LDA &FE60 : PHA : LDA &FE62 : PHA
  LDX &70
  LDY #0
.page
  LDA #15
  SEI
  STA &FE62
  STX &FE60  
  STX &FE32  
  STA &FF30,X
  STX &FE30  
.loop
  LDA (&72),Y
  STA (&74),Y
  INY
  BNE loop
  LDA &F4
  STA &FE30
  CLI
  INC &73
  INC &75
  DEC &71
  BNE page
  PLA : STA &FE62 : PLA : STA &FE60
 RTS
The saving and restoring &FE60 and &FE62 was suggested by duikkie to try and preserve the user port settings, but it doesn't stop the next MMC call from failing.
Last edited by tricky on Wed Mar 08, 2023 11:37 am, edited 1 time in total.
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

ah a little more complex than I thought, thanks for the code

yeah the writing and reading back idea was to write a small block of data containing a pattern that could be verified or even a seeded set random numbers something like that. all values must pass to confirm its ram

I finally had a breakthrough with encoding the font into my weird format, the issue i was having was trying to interpret the various image file formats like png bmp tiff etc etc then I discovered that the old photoshop 7 im using has an option to save as raw ! no header junk and all pixels are saved in sequence as 1 byte per pixel 00=black and 01=white perfect

I wrote a little C program called fontmaker to take these raw files and encode them as my font format, I havent done much else lately as I dont have much spare time but I'll continute here and there and slowly slowly i'll get there

my bbc code so far is based on the demo program called relocdemo.6502 that came with beebasm and was really useful getting me started

i'll post everything so far, maybe the printing routine might be useful to someone ?

fontmaker
main.c
(3.38 KiB) Downloaded 109 times
original png font
font.png
font.png (485 Bytes) Viewed 15133 times
font saved as raw
font.raw.zip
(425 Bytes) Downloaded 106 times
font converted by fontmaker (actually only 255 bytes when unzipped)
font.bin.zip
(381 Bytes) Downloaded 100 times
ladybug.asm
ladybug.asm.zip
(3.97 KiB) Downloaded 104 times
bootable disk image for beebem
ladybug.ssd.zip
(832 Bytes) Downloaded 108 times
not much to see yet, slowly slowly
screenshot.png
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

thanks tricky, I must do some sprite tests soon its most urgent !

but in the mean time I quickly wrote a printString function that prints a text string thats after the jsr (pops the return address to get a pointer to the text)
called like this

Code: Select all

	jsr printString
	equs "hello world. ", &ff

	jsr printString
	equs "the quick brown fox jumps over the lazy dog.", &ff
	

Code: Select all

;------------------------------------------------------------------------------------------------------------------------
; printString					print text string terminanated by byte with bit 7 set
;------------------------------------------------------------------------------------------------------------------------
; entry			string			string is read from memory following the jsr
;------------------------------------------------------------------------------------------------------------------------
; workspace		printStringTextPtr	pointer to the text string
;------------------------------------------------------------------------------------------------------------------------
; exit			PC			program flow is returned to first code byte following string terminator
;			printChrAddr		points to next chr position on screen
;			A			destroyed
;			X			destroyed
;			y			destroyed
;------------------------------------------------------------------------------------------------------------------------

.printString

	clc					; pull return address (text string - 1) and adjust
	pla
	adc #1
	sta printStringTextPtr
	pla
	adc #0
	sta printStringTextPtr + 1

.printStringLoop		

	ldy #0					; get chr from text string
	lda (printStringTextPtr), y

	bmi printStringEnd			; if bit 7 set then end of text string
	
	jsr printChr				; else print chr

	inc printStringTextPtr			; move onto next chr in text string
	bne printStringLoop
	inc printStringTextPtr +1
	bne printStringLoop
	
.printStringEnd

	inc printStringTextPtr			; fixup return address
	bne printStringExit
	inc printStringTextPtr +1

.printStringExit

	jmp (printStringTextPtr)		; done. return to program
screenshot.png
screenshot.png (6.83 KiB) Viewed 15095 times
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

still havent had the time to write the sprite code but I will get to it soon

spent 2 mins and wrote a prng based on some code I once wrote for a pic microcontroller, originally the number of bits was much larger and used a shift and xor for every byte pair but I have cut it down to just 1 stage for speed. hopefully its still random enough for the game

as a test I filled the screen with its output and it looks fairly ok

maybe someone has a better/faster prng ?

Code: Select all

;-------------------------------------------------------------------------------------------------------------
; randomNumber					generate an 8 bit random number
;-------------------------------------------------------------------------------------------------------------
; entry			none
;-------------------------------------------------------------------------------------------------------------
; workspace		randomSeed		3 bytes used to calculate next random number
;-------------------------------------------------------------------------------------------------------------
; exit			A			8 bit random number
;-------------------------------------------------------------------------------------------------------------

.randomNumber

	lda randomSeed
	sta randomSeed + 2
	asl a
	rol randomSeed + 1
	lda randomSeed + 1
	eor randomSeed + 2
	sta randomSeed + 2
	lda randomSeed
	sta randomSeed + 1
	lda randomSeed + 2
	sta randomSeed
	
	rts
prng.png
prng.png (26.16 KiB) Viewed 15016 times
Image Image Image Image
User avatar
cardboardguru
Posts: 239
Joined: Fri Mar 09, 2018 10:26 pm
Contact:

Re: Lady Bug

Post by cardboardguru »

lovebug wrote: Mon Feb 22, 2021 6:38 pm maybe someone has a better/faster prng ?
Funnily enough I was looking for a 6502 PRNG last night, and found this, which I'm now using. Looks similar to yours but not the same. Looked good to me because it was short and has no loops, so it must be fast. I can't vouch for it, but the writer of the article knows far more about PRNGs than I do, so it was good enough for me.

One thing to watch out for is that the 3 values need initialising with as non-zero seed. It didn't work for me at first as I hadn't seeded it.

https://wimcouwenberg.wordpress.com/202 ... processor/
Last edited by cardboardguru on Mon Feb 22, 2021 7:08 pm, edited 2 times in total.
EdwardianDuck
Posts: 326
Joined: Thu Aug 10, 2017 9:07 pm
Contact:

Re: Lady Bug

Post by EdwardianDuck »

I used one of the examples from http://6502.org/source/integers/random/random.html, but it did need a fair bit of memory for workspace.

Jeremy
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

thanks for the 2 links guys

the first one at https://wimcouwenberg.wordpress.com/202 ... processor/ does look very similar to the code I wrote for the pic micro controller

the 2nd one at http://6502.org/source/integers/random/random.html just blew my brains :lol:

I was just now googling about linear feedback shift register prng's and the math also blew my brains :lol:

I dont think i'll ever be an expert in this field :P

I just dumped out a few bytes of hex from the prng and its probably random enough for the game
prng-hex.png
prng-hex.png (4.58 KiB) Viewed 15001 times
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I just found a random noise program in the acorn atom atomic theory and practice manual thats smaller and faster

Code: Select all

10 REM Random Noise
20 DIM L(2),NN(1),P(-1)
30 C=#B002
40[
50:NN0 LDA L; STA C
60 AND @#48; ADC @#38
70 ASL A; ASL A
80 ROL L+2; ROL L+1; ROL L
90 JMP NN0
100]
110 LINK NN0
but sadly its not so random :(
rnd-atom.png
rnd-atom.png (25.86 KiB) Viewed 14990 times
Image Image Image Image
User avatar
tricky
Posts: 7698
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Lady Bug

Post by tricky »

Definitly not prng, but this is what I use ;)

Code: Select all

.rand
{
	lda rand_last
	asl a
	asl a
	clc
	adc rand_last
	clc
	adc #&45
	sta rand_last
//	eor SysViaT1CL
	rts
}
The eor SysViaT1CL is just a bit of extra noise, but depending on the game it could be enough on its own!
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

@tricky I just tried your code including the eor with t1 lo, youre right its not random but it is pretty 8)
prng-tricky.png
prng-tricky.png (14.17 KiB) Viewed 14986 times
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

@cardboardguru I just tried the prng from the site you posted and its very good
prng-cardboardguru.png
prng-cardboardguru.png (26.01 KiB) Viewed 14980 times
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

I did a final test of the sequence run length of the wimcouwenberg and mine

wimcouwenberg uses a 24 bit seed and gave a length of (2 ^ bits) - 1 bytes (16777215 bytes) before the pattern repeats
prng-wimcouwenberg-length.png
prng-wimcouwenberg-length.png (25.97 KiB) Viewed 14974 times

my prng uses only 16 bits of the 24 for the actual seed the other byte is just workspace and gave a length of (2 ^ (bits - 1)) - 1 bytes (32767 bytes), ive lost a seed bit somewhere #-o
prng-lovebug-length.png
prng-lovebug-length.png (26.13 KiB) Viewed 14974 times
Image Image Image Image
User avatar
TobyLobster
Posts: 618
Joined: Sat Aug 31, 2019 7:58 am
Contact:

Re: Lady Bug

Post by TobyLobster »

16 bit XORSHIFT is 20 bytes (without the code to seed the values) and 36 cycles
http://www.retroprogramming.com/2017/07 ... 1821379366
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

thanks TobyLobster gonna try this one now, heh what started out as a quick 2 min prng has dragged on XD

brb
Image Image Image Image
User avatar
lovebug
Posts: 1741
Joined: Sun Jan 31, 2021 5:07 pm
Location: Magrathea
Contact:

Re: Lady Bug

Post by lovebug »

yeah that one is nice, uses only 2 byte seed and gives the full length count of 65535. thats lovely thanks TobyLobster

I think we've found a winner :)
prng-retroprogramming-length.png
prng-retroprogramming-length.png (26.06 KiB) Viewed 14963 times


thanks everyone for your help and I actually had fun trying these out
Image Image Image Image
Post Reply

Return to “new projects in development: games”