bogax
-
Content Count
902 -
Joined
-
Last visited
Posts posted by bogax
-
-
here's a bit of javascript to generate code
save it as html and open it in a browser
-
I wrote a short routine to test it and apparently rand16 never returns 0
dim rand16 = aux1 scorecolor = $1E COLUPF = $76 for i = 0 to 255 for j = 0 to 255 if rand = 0 then score = score + 1 if !(j & $3F) then drawscreen next score = score + 1000 next scorecolor = $3A loop drawscreen goto loop
-
despite of what I said here
rand actually ranges 1..255
if you set it to 0 it'll stay 0 (its an LFSR)
in that link I describe one way.
edit
if you use rand16, which I recommend, it can (and I assume, does) return 0
-
or you could actually do it in bB

vblank rem ** Enable the TIA bug that causes missile0 to be repeated ; asm ; lda #$ff ; sta HMM0 ; lda #$c0 ; sta WSYNC ; sta HMOVE ; sleep 5 ; sta HMM0 ; end HMM0 = $FF WSYNC = $C0 : HMOVE = $C0 aux1 = $C0 : HMM0 = $C0 return
-
6
-
-
here I've rearranged your code to be more to my liking
I moved the kernel options stuff to the beginning
I added a player1color statement
I poked holes in player0 so player1 would show through
I moved the player0 color assignment (COLUP0 = $00) to just before drawscreen
(you'll end up with COLUP0 being the leftover score color from the previous drawscreen otherwise)
edit COLUP0 has to be set before the next drawscreen but it doesn't matter where
set romsize 2k
set kernel_options player1colors pfcolors
set optimization inlinerand
set optimization speed
player1:
%00000000
%00011000
%00100000
%01000000
%01110000
%11101000
%10100000
%11100000
end
player1color:
$42
$44
$46
$48
$4A
$4C
$4E
$50
end
player0:
%11100111
%10100101
%11101111
%01100100
%01001100
%00000100
%00001111
%00000000
end
pfcolors:
$00
$1E
$1E
$1E
$00
$92
$D6
$1E
$40
$C0
$C0
end
playfield:
................................
.........................XXXX...
.........................XXXX...
.........................XXXX...
................................
...............................X
..............................XX
............................XXXX
.........................XXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
COLUBK = $BE
player0x=20
player0y=72
loop
COLUP0 = $00
drawscreen
AUDF0 = 20
AUDC0 = 3
AUDF0 = 3
if joy0left then player0x=player0x-1
if joy0right then player0x=player0x+1
if joy0up then player0y=player0y-1
if joy0down then player0y=player0y+1
player1x=player0x
player1y=player0y-2
goto loop
-
Open System Status Messages
DateMessageService11/06/1606:10 AM PST: Recent domain name verification emailsYou may have received an email recently from us with the following subject line:
VERIFICATION REQUIRED – Please verify your domain name(s) as soon as possiblePlease rest assured that these emails are legitimate. ICANN (the governing body for the Internet) requires that all domains have accurate contact information, and we occasionally need to verify this information. Read more in this Help Center article.
We ask that you promptly follow the verification instructions in this email. Unverified domains may be suspended until verification is completed.
Thank you for your attention to this matter.
-
oh hell
it is my changes
temp1digit2 is a 16 bit pointer so it needs two (consecutive) bytes
if you specify y it will use y and z
specify z and in the version of bB that I'm using it'll use z and aux1
if you're using RevEng's latest and greatest I think he changed that
edit
since its an alternative to the normal score the logical thing is probably to use the scorepointers
so it would be temp1digit2 = scorepointers
but I haven't tested that
-
your temp variable has to be persistent across drawscreens so I don't think that will work
if you go into the minkernel and change temp1digit2 = stack1 to, say, temp1digit2 = z
it seems to work
the minikernel its self uses one stack slot so drawscreen + minikernel must be three
that is, one for the call to drawscreen one for drawscreens call to the minikernel and one internal to the minikernel
edit
it looks to me like the jsr in the minikernel is unneccesary so it could probably be removed (with some other modifications to the minikernel)
more edit
here I commented some stuff out and moved things around a bit
I commented out the four scores stuff and removed the jsr
I changed the scores so they use the score variables instead of stack space
I used z for temp1digit2 but you could probably use something else
you can see if it works for you I didn't test it much
even more edit
updated to use scorepointers for the temp1digit2 score pointer (instead of z, see below)
-
SubMainLoop is a goto loop instead of gosub. However, I tried calling SubServeBall from the main loop instead, and it fixed the problem. Color me surprised, though.
oops you're right I misread it
however you use on-gosub in SubPlayerScore and on-gosub uses two
it's not hard to rig an equivalent to on-gosub that doesn't use two but it needs a dab of asm and it's a little uglier code wise
for your problem you could probably go into the minikernel and give it a different variable than the stack location it uses
edit:
it looks like the minikernel uses four bytes of stack and you've only got ten
drawscreen uses four at least (with the call to the minikernel)
sounds like when your code works it's using six
so the way I'm figuring it doesn't add up
hmm
-
you're three deep SubMainLoop, SubPlayerScore, SubServeBall
and the kernel (drawscreen) uses two.
-
I think temp7 is only used for bank switching so it's probably safe as long as you're not using multiple banks
if all you're doing is drawscreen I think the aux variables (at least some of them) should be safe (they're the bottom of the stack)
however they may be used by the kernel depending on the options
and of course var44..47
-
here I've rearranged your code to be more to my liking
I moved the kernel options and such to the first thing
I removed the multisprite kernel, it doesn't have the options
I added player1colors to the kernel options
I swapped player0 and player1 'cause player1 has the colors option
I turned on the pfscore bar(s)
I intialized the left score bar
I moved the (setup) stuff that you don't need in the mainloop in
to a subroutine at the end
I initialized the player0 and player1 locations to where they'd be visible when the game starts
I put the player0 and player1 location intialization all on the same
line because they're all getting intialized to the same value and it will
save time and space (in that case) if they're all (consecutively) on the same line
I added actual rem statements to what I took to be rem statements
I did not fix player0 to follow player1
don't know what I might have messed up (eg not sure what you had in mind)
set tv ntsc
set kernel_options player1colors pfcolors pfheights
set romsize 4k
set smartbranching on
const pfscore = 1
rem gamestart
gosub setup
MainLoop
if joy0left then player1x=player1x-1:if player1x<10 then player1x=10
if joy0right then player1x=player1x+1:if player1x>137 then player1x=137
if joy0up then player1y=player1y-1:if player1y<7 then player1y=7
if joy0down then player1y=player1y+1:if player1y>99 then player1y=99
drawscreen
goto MainLoop
setup
pfscorecolor = $26 : pfscore1 = %11111111
player0x = 32 : player0y = 32 : player1x = 32 : player1y = 32
AUDV0 = 6
AUDC0 = 2
AUDF0 = 7
player1color:
$40
$40
$40
$40
$40
$00
$06
$06
$02
end
rem motorbike
player1:
%11100000111
%10101110101
%11101000111
%00011101000
%00000101000
%00011010000
%00000010000
%00001111100
%00001000100
end
rem player
player0:
%000001100
%000001000
%000001000
%000001000
%001110000
%001000000
%011111000
%010100000
%011100000
end
pfheights:
8
8
8
8
8
8
8
8
8
8
8
end
pfcolors:
$9C
$9A
$8A
$88
$74
$72
$C4
$C2
$C0
$00
$00
end
playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXX
XXXXXXXXXXXXXXXXXXXXXXXXX..XXXXX
XXXXXXXXXXXXXXXXXXXXXXXX...XXXXX
XXXXXXXXXXXXXXXXXXXXXX.....XXXXX
XXXXXXXXXXXXXXXXXXX........XXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
return
-
the kernel uses temp4, temp5 they won't survive drawscreen
-
2
-
-
With this kernel it would stay the same compiled size until enough saving tricks were done, then it jumped from 277 left to 344 left to 439 - the final being when I made the empty sprites just one line...
I probably broke something, but I couldn't see anything wrong.
Just guessing
if you read an item in a table from the next page it takes longer
since timing is critical in the kernel bB pads the code with 0s so that
(some) tables (eg sprite data) don't cross a page boundary
if you remove enough stuff, suddenly the 0 padding disappears
and the space left jumps
I think you could squeeze out a few more bytes
-
Sure, no problem. This community has helped me numerous times and it would be great to be able to contribute for once! But this isn't very elegant as can be complicated.
First, you need to define your graphics data as a data statement:
data my_sprite:
{sprite data here}
end
You'll also want the color information. You can use that as a data statement too.
data my_sprite_color:
{colors}
end
You can put this anywhere, but I put it in bank 7 (which is reserved for graphics data anyway.)
.
.
.
To change the sprite to something else, all you need to do is get the 4 bytes from whereever you put them, and write them again. Once you get one sprite working it's trivial to use others. What it isn't is fast.
when I tryed to put stuff in bank 7 DASM complained
did you do anything special to get it to work?
why not have the sprite addresses in ROM?
-
Bogax,
If I'm tracking what you are saying. That the rand is wasting cycles and I should just go with a constant number to make the program run faster. I noticed if I turned off the fruit part the changing of rooms works better. If I turn off the ghosts of course it works a lot better.
more pointing out that they're not very evenly distributed
but I don't know what you want
-
Bogax,
Thanks for the tips. I read that return otherbank and thisbank are faster than just return. I will look through the code to remove them where not needed.
For moving one ghost at a time. Is there any material to read up on that? I plan to look at the code some more tomorrow, thanks.
you use return otherbank for the first four ghost routines in bank 5 but I think you only call them from bank 5
if you have a spare bit somewhere use it as a one bit frame counter
do two ghosts when it's 0 and the other two when it's 1
-
rand&108 will produce one of 16 possible numbers
0, 4, 8, 12, 32, 36, 40, 44, 64, 68, 72, 76, 96, 100, 104 or 108
this shows a histogram for the numbers 0..31
R# 0 Is just rand
R# 1 is rand & 108
R# 2 is rand & 109
R# 3 is rand & 110
-
I doubt if the gosubs are much of a problem
I notice you're using return otherbank in several place where it looks like you don't need that
since the ghosts are moving slowly try increasing the velocity but only moving one ghost per frame
-
in the standard kernel rand produces a jsr to randomize and produces a new number
with the DPC+ kernel it just loads rand unless you've specified inline rand
so how often does DPC+ update rand?
or does DPC+ not touch rand at all?
-
it would be something like
; you have to get temp1 in what ever bank has room_shape
temp1 = room_shape[room] : goto draw_room_shape bank6
then in bank6
draw_room_shape
on temp1 goto rs0 rs1 rs2 rs3 rs4 rs5 rs6 rs7 rs8 rs9 rs10 rs11 rs12 rs13 rs14 rs15 rs16 rs17 rs18 rs19 rs20 rs21 rs22 rs23 rs24
I used rs instead of draw_room_shape because
there's a limit to how much you can put on a line
if you just have to you can break the line up
or there are ways to put/use the addresses (labels) in data statements
which involves microscopic amounts of asm
I'd just use short labels if possible
you could have up to 256 labels in two data statements and data statements can span multiple lines
temp2 is right after temp1
the jmp( ) instuction takes the low byte of its target from the location specified (in this case temp1)
and the high byte from the following location
bB prepends a "." to labels in the asm it emits
> specifies the high byte of the (two byte) label, < specifies the low byte
so one way to use data statements would be
temp2 = labelhi[temp1] : temp1 = labello[temp1]
asm
jmp(temp1)
end
data labelhi
>.draw_room_shape_0,
>.draw_room_shape_1,
>.draw_room_shape_2,
(etc)
.
.
>.draw_room_shape_24,
end
data labello
<.draw_room_shape_0,
<.draw_room_shape_1,
<.draw_room_shape_2,
(etc)
.
.
<.draw_room_shape_24,
end
-
added a scatter plot mode
the scatter plot plots a pixel with x = the previous number and y = the current number
it should work now with routines 0..99 although it still has the same 20
you'd need to add a routine and change the Number_of_Rand_Routines constant
and change the on_gosub that selects amongst the routines
rearranged the function selection
now you move right and left to select a function and use up_down to change it
there's an indicator for what you're doing/where you are
the indicator is just a character or two over the score digits
the three score digits on the left are
R reseeding enable
S scatter table enable
L LCG enable
1 is enabled 0 disabled
the fourth digit from the left is the rand select
R8 0 for 8 bit rand
16 1 for rand 16
L 2 for the LCG
the two digits on the right are the routine select number
R# (use your imagination) 0..19
if the rand digit is 2 for the LCG that's all you get (no rand8 or rand16)
if LCG is selected the LCG enable bit is set (but has no effect)
and if the scatter table is enabled it will look up a number using the LCG result (which it didn't do before)
otherwise the same
rand8 or rand16 get XORed with the LCG if it's enabled
the result is run through the scatter table if it's enabled
if the LCG is enabled the scatter function just looks up a new value in the scatter table
if LCG is disabled it XORs with the previous MyRandSeed value and returns that and
uses the result to look up a new MyRandSeed value to XOR with next time (no particular reason for the lag)
to switch between histogram and scatter plot hold the joy0fire and the mode will toggle every 2 seconds
as indicated by the score color.
whatever you release fire on is what you get
I also added a bunch of extra wordy names to the code for RT (but no leading under scores, you've got to draw the line somwhere
)
edit: fixed a couple bugs
now it's perfect so I expect this to be the final version
-
almost done
I was thinking of integrating a scatter plot function
and maybe a modified score kernel-minikernel to make
something less cryptic than numbers for the
random number selection
fixed some more bugs
moved some other stuff to subroutines
added comments
-
1
-
-
Thanks. I am still trying to figure out a way to stop the scalines. I did fix the fruit issue and made better mazes. Also working on a few other things for this game. But all the praise should go to Random Terrain, Atari2600land and a few others as I used their code and merged it together to make this game.
there are some odd things about your codethe first odd thing is that you waste time (and code) on all those if testsedit: oops you do go to those labelsfixed the examplesuppose you're in room 1you don't call any of those labels from anywhere so the only way to getto a test for room 1 is to fall through all those if testsbut you goto __Exit_Return after the first block of ifs sohow will you ever get to the if room = 1 test if you're in room 1?in the third block of ifs you test player0x > 130 except for room 8 where it's132 is that what you meant to do?you do something only if player0x = 76 || player0y = 82so why not test for that and bug out if they fail, and not spend time (and code)on tests you don't need?__Pac_Man_Exit_Top if room = 0 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 4 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 5 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 6 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 7 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 8 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 9 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 10 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 11 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 13 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 14 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 15 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 18 && player0y < 15 && player0x = 76 then goto __Unblock_Top if room = 19 && player0y < 15 && player0x = 76 then goto __Unblock_Top goto __Exit_Return __Pac_Man_Exit_Bottom if room = 15 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 14 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 16 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 24 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 21 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 19 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 18 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 5 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 10 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 9 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom if room = 11 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom ; Set CTRLPF so light sprite moves behind playfield. using 9 moves player9 behind the playfield. if room = 12 && player0y > 140 && player0x = 76 then goto __Unblock_Bottom goto __Exit_Return __Pac_Man_Exit_Right if room = 0 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 1 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 3 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 6 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 7 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 8 && player0x = 132 && player0y = 82 then goto __Unblock_Right if room = 13 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 16 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 17 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 18 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 19 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 20 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 21 && player0x > 130 && player0y = 82 then goto __Unblock_Right if room = 22 && player0x > 130 && player0y = 82 then goto __Unblock_Right goto __Exit_Return __Pac_Man_Exit_Left if room = 1 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 2 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 4 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 5 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 6 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 7 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 14 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 15 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 16 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 18 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 17 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 20 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 21 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 22 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 24 && player0x < 21 && player0y = 82 then goto __Unblock_Left if room = 23 && player0x < 21 && player0y = 82 then goto __Unblock_Left goto __Exit_Return
here's some example code (I don't promise it's right)I put flags in a look up table for the room testthe room test(s) only happen after determining that the otherconditions are met(I've asssumed that the room 8 player0x-unblock_right test was ment to be 130)temp1 = exit_flags[room] if player0x <> 76 || player0y >= 15 then skip_to_Exit_Return temp1 = exit_flags[room] : if temp1{0} then goto __Unblock_Top goto __Exit_Return __Pac_Man_Exit_Bottom if player0x <> 76 || player0y <= 140 then skip_to_Exit_Return temp1 = exit_flags[room] : if temp1{1} then goto __Unblock_Bottom skip_to_Exit_Return goto __Exit_Return __Pac_Man_Exit_Right if player0y <> 82 || player0x >= 130 then skip_to_Exit_Return temp1 = exit_flags[room] : if temp1{2} then goto __Unblock_Right goto __Exit_Return __Pac_Man_Exit_Left if player0y <> 82 || player0x >= 21 then skip_to_Exit_Return temp1 = exit_flags[room] : if temp1{3} then goto __Unblock_Left goto __Exit_Return data exit_flags %00000101, %00001100, %00001000, %00001100, %00001001, %00001001, %00001101, %00001101, %00000101, %00000011, %00000011, %00000011 %00000010, %00000101, %00001011, %00001011, %00001110, %00001100, %00001111, %00000111, %00001100, %00001110, %00001100, %00001000 %00001010 endfor this block of codeI'd suggest you jump into bank6 and use an on..goto statementto select the draw_room_shape routineit will take much less code and less timeif you can save room you can fit more in a bank and not have to wastetime doing bank switchesif room_shape[room] <> 12 then gosub __Pac_Man_Playfield_Colors bank6 if room_shape[room] = 0 then goto draw_room_shape_0 bank6 if room_shape[room] = 1 then goto draw_room_shape_1 bank6 if room_shape[room] = 2 then goto draw_room_shape_2 bank6 if room_shape[room] = 3 then goto draw_room_shape_3 bank6 if room_shape[room] = 4 then goto draw_room_shape_4 bank6 if room_shape[room] = 5 then goto draw_room_shape_5 bank6 if room_shape[room] = 6 then goto draw_room_shape_6 bank6 if room_shape[room] = 7 then goto draw_room_shape_7 bank6 if room_shape[room] = 8 then goto draw_room_shape_8 bank6 if room_shape[room] = 9 then goto draw_room_shape_9 bank6 if room_shape[room] = 10 then goto draw_room_shape_10 bank6 if room_shape[room] = 11 then goto draw_room_shape_11 bank6 if room_shape[room] = 12 then goto draw_room_shape_12 bank6 if room_shape[room] = 13 then goto draw_room_shape_13 bank6 if room_shape[room] = 14 then goto draw_room_shape_14 bank6 if room_shape[room] = 15 then goto draw_room_shape_15 bank6 if room_shape[room] = 16 then goto draw_room_shape_16 bank6 if room_shape[room] = 17 then goto draw_room_shape_17 bank6 if room_shape[room] = 18 then goto draw_room_shape_18 bank6 if room_shape[room] = 19 then goto draw_room_shape_19 bank6 if room_shape[room] = 20 then goto draw_room_shape_20 bank6 if room_shape[room] = 21 then goto draw_room_shape_21 bank6 if room_shape[room] = 22 then goto draw_room_shape_22 bank6 if room_shape[room] = 23 then goto draw_room_shape_23 bank6 if room_shape[room] = 24 then goto draw_room_shape_24 bank6
-
1
-

Do Rand have to start at 0?
in batari Basic
Posted
hmm
if the download is not working for you you could use the raw button and copy and paste to a text editor and save it as html from there