Posted Sat Aug 16, 2008 4:15 AM
Posted Sat Aug 16, 2008 6:21 AM
Posted Sat Aug 16, 2008 6:30 AM
Nukey Shay, on Sat Aug 16, 2008 7:21 AM, said:
Edited by Random Terrain, Sat Aug 16, 2008 7:52 AM.
Posted Sat Aug 16, 2008 7:14 AM
Edited by Nukey Shay, Sat Aug 16, 2008 7:15 AM.
Posted Sat Aug 16, 2008 8:32 PM
Nukey Shay, on Sat Aug 16, 2008 8:14 AM, said:
Posted Sat Aug 16, 2008 9:31 PM
Posted Sun Aug 17, 2008 1:17 AM
Random Terrain, on Sat Aug 16, 2008 6:15 AM, said:
rem * Nybble me this, Batman! rem * Variable "a" will be used to store two nybble values. rem * You need to include div_mul.asm for this. include div_mul.asm rem * Store the two values in "b" and "c," just for now. b = 5 c = 10 rem * Use multiplication and addition to set "a." rem * The "b" value will go in the high nybble, rem * and the "c" value will go in the low nybble. a = 16 * b + c rem * Now clear "b" and "c." b = 0 c = 0 rem * Here's how to retrieve the two nybbles: b = a // 16 c = temp1 // 16 c = temp1 rem * There's a bug in the "//" routine that causes the rem * bits of remainder temp1 to be in reverse order, rem * so that's why we do "//" again on temp1. rem * Now let's use the score to display them: score = 0 if b > 0 then for i = 1 to b : score = score + 1000 : next if c > 0 then for i = 1 to c : score = score + 1 : next COLUBK = $00 scorecolor = $1A loop_1 drawscreen if !joy0fire then loop_1 rem * Here's how to change just the high nybble (to 3): a = a & %00001111 a = a | 16 * 3 rem * Here's how to change just the low nybble (to 6): a = a & %11110000 a = a | 6 rem * Now get and display the new values: b = a // 16 c = temp1 // 16 c = temp1 score = 0 if b > 0 then for i = 1 to b : score = score + 1000 : next if c > 0 then for i = 1 to c : score = score + 1 : next loop_2 drawscreen goto loop_2Michael
Posted Sun Aug 17, 2008 1:20 AM
rem * Nybble me this, Batman! rem * Variable "a" will be used to store two nybble values. rem * You need to include div_mul.asm for this. include div_mul.asm rem * Store the two values in "b" and "c," just for now. b = 5 c = 10 rem * Use multiplication and addition to set "a." rem * The "b" value will go in the high nybble, rem * and the "c" value will go in the low nybble. a = 16 * b + c rem * Now clear "b" and "c." b = 0 c = 0 rem * Here's how to retrieve the two nybbles: b = a / 16 c = a & %00001111 rem * Now let's use the score to display them: score = 0 if b > 0 then for i = 1 to b : score = score + 1000 : next if c > 0 then for i = 1 to c : score = score + 1 : next COLUBK = $00 scorecolor = $1A loop_1 drawscreen if !joy0fire then loop_1 rem * Here's how to change just the high nybble (to 3): a = a & %00001111 a = a | 16 * 3 rem * Here's how to change just the low nybble (to 6): a = a & %11110000 a = a | 6 rem * Now get and display the new values: b = a / 16 c = a & %00001111 score = 0 if b > 0 then for i = 1 to b : score = score + 1000 : next if c > 0 then for i = 1 to c : score = score + 1 : next loop_2 drawscreen goto loop_2Michael
Posted Sun Aug 17, 2008 1:49 AM
Posted Sun Aug 17, 2008 2:18 AM
SeaGtGruff, on Sun Aug 17, 2008 2:20 AM, said:
Nukey Shay, on Sun Aug 17, 2008 2:49 AM, said:
Posted Sun Aug 17, 2008 2:27 AM
Posted Sun Aug 17, 2008 4:00 AM
SeaGtGruff, on Sun Aug 17, 2008 2:20 AM, said:
counter01 = counter01 + 17
temp1 = counter01 / 16 if temp1<animtrigger then goto skipanim
counter01= counter01 & %00001111
temp1=counter01 & %00001111 if temp1<speed_current then goto skip_all
counter01 = counter01 & %11110000
Edited by Random Terrain, Sun Aug 17, 2008 4:01 AM.
Posted Sun Aug 17, 2008 12:11 PM
Nukey Shay, on Sun Aug 17, 2008 2:49 AM, said:
temp2 = a // 16 : rem * to get the high nybble in temp2 rem * and now temp1 already contains the low nybbleBut when I displayed the results in the score, the low nybble was wrong. And when I checked the compiled assembly code, I realized that the LSR and ROL instructions were moving the remainder into temp1 with the bits in reverse order. I think the generic "//" operation uses a routine in the div_mul16.asm include file, but if the bB compiler sees "// 16" (or 2, 4, 8, 16, 32, 64, or 128) it apparently just uses LSR for the division, and ROL for the remainder. The LSR is okay, but I think it would be easier/better to put the remainder in temp1 using AND:
; current buggy code: ; b = a // 16 LDA a ldx #0 stx temp1 lsr rol temp1 lsr rol temp1 lsr rol temp1 lsr rol temp1 STA b
; suggested replacement code: ; b = a // 16 LDA a STA temp1 AND %00001111 lsr lsr lsr lsr STA bThe bB compiler would fill the section from "AND %00001111" through the last "LSR" with the appropriate bit mask and number of LSRs as determined by the power of 2 after the "//" operand. If this gets fixed in the next version of bB, then the "//" operation would be the simplest method, as shown in my first example above ("temp2 = a // 16" which would set temp1 to the low nybble automatically).
Edited by SeaGtGruff, Sun Aug 17, 2008 12:12 PM.
Posted Thu Aug 21, 2008 5:41 AM
Posted Thu Aug 21, 2008 10:46 AM
Random Terrain, on Thu Aug 21, 2008 6:41 AM, said:
Posted Thu Aug 21, 2008 11:50 AM
CurtisP, on Thu Aug 21, 2008 11:46 AM, said:
Posted Thu Aug 21, 2008 12:11 PM
Posted Wed Aug 27, 2008 5:47 PM
Artlover, on Thu Aug 21, 2008 2:11 PM, said:
0 members, 0 guests, 0 anonymous users