Invader
Posted: 09 Jul 2020, 03:54
It runs on ROMv3 or above, latest .gt1 file is attached:
https://www.youtube.com/watch?v=VK8WBsOlMFM
- Runs on ROMv3 or higher.
- Will have authentic AI modeled after the original when it is complete.
- There are 50 invaders instead of 55.
- The invaders are 1 to 2 pixels thinner than the original.
- The invaders are stacked closer together both horizontally and vertically due to limitations in Gigatron pixel real estate, (this makes the game somewhat easier).
- The code follows the original when drawing the invaders, i.e. one invader per 60Hz frame drawn from left to right, bottom to top.
- Collision detection is performed trivially as a screen-space to invader array space transformation, rather than cycling through every invader and testing against the player bullet, (bounding boxes/circles, pixel reading, etc).
- Collision detection is even faster than partition space algorithms or divide and conquer techniques, but suffers from the slight disadvantage that the mapping process doesn't take into account invaders with slightly smaller sizes, (such as the top row). So that hits can be registered when in fact the player bullet was missing by one pixel either side, (this makes the game somewhat easier).
- Uses many tricks to save every single byte and vCPU cycle possible, but there are many more opportunities to squeeze out more bytes and cycles.
- Uses embedded ASM code within the BASIC code to draw the bullets and damage the barriers.
- The main loop always runs at 60Hz in screen mode 2 until there are around 4 invaders left, then the frame rate starts to drop as the main loop wastes more and more time checking empty invaders slots in the invader data structure.
- The solution to the tanking frame rate is to traverse an ever decreasing linked list, instead of traversing a constant sized 2D array.
Here is an example of how the player bullet is drawn using embedded ASM code, it's trivial to use vCPU code within gtBASIC and access variables, subs/procs/labels, etc.
Link to video:https://www.youtube.com/watch?v=VK8WBsOlMFM
- Runs on ROMv3 or higher.
- Will have authentic AI modeled after the original when it is complete.
- There are 50 invaders instead of 55.
- The invaders are 1 to 2 pixels thinner than the original.
- The invaders are stacked closer together both horizontally and vertically due to limitations in Gigatron pixel real estate, (this makes the game somewhat easier).
- The code follows the original when drawing the invaders, i.e. one invader per 60Hz frame drawn from left to right, bottom to top.
- Collision detection is performed trivially as a screen-space to invader array space transformation, rather than cycling through every invader and testing against the player bullet, (bounding boxes/circles, pixel reading, etc).
- Collision detection is even faster than partition space algorithms or divide and conquer techniques, but suffers from the slight disadvantage that the mapping process doesn't take into account invaders with slightly smaller sizes, (such as the top row). So that hits can be registered when in fact the player bullet was missing by one pixel either side, (this makes the game somewhat easier).
- Uses many tricks to save every single byte and vCPU cycle possible, but there are many more opportunities to squeeze out more bytes and cycles.
- Uses embedded ASM code within the BASIC code to draw the bullets and damage the barriers.
- The main loop always runs at 60Hz in screen mode 2 until there are around 4 invaders left, then the frame rate starts to drop as the main loop wastes more and more time checking empty invaders slots in the invader data structure.
- The solution to the tanking frame rate is to traverse an ever decreasing linked list, instead of traversing a constant sized 2D array.
Here is an example of how the player bullet is drawn using embedded ASM code, it's trivial to use vCPU code within gtBASIC and access variables, subs/procs/labels, etc.
Code: Select all
proc drawPlayerBullet
'no bullets while invader is asploding
if &(ixy) then return
'no bullet so exit
if &(pbullet.hi = 0) then return
asm 'setup SYS function
LDWI SYS_VDrawBits_134
STW giga_sysFn
endasm
if peek(pbxy + &h0000) &&= &h0C
pbullet.lo = 0
gosub smashBarrier
endif
asm 'setup SYS params
LDWI 0x3F00
STW giga_sysArg0
LDW _pbxy
STW giga_sysArg4
endasm
if &(pbullet.lo)
asm 'draw bullet
LDI 0xF8
ST giga_sysArg2
SYS 134
endasm
pbxy.hi = pbxy.hi - 2
if pbxy.hi &&< 8
pbullet = 0
asm 'erase bullet if top of screen
LDI 0x00
ST giga_sysArg2
SYS 134
endasm
endif
return
endif
asm 'erase bullet if pbullet.lo = 0
LDI 0x00
ST giga_sysArg2
SYS 134
endasm
pbullet = 0
endproc