Path: blob/master/Assets/Lua/PCE/Castlevania_Rondo_of_Blood.lua
2 views
--Castlevania: Rondo of Blood12fill = 0x64FFC8C83line = 0xFFFFC8C845function drawObjInfo()67for i = 0,88 do89objX = mainmemory.read_u8(0xBC8+i)10objY = mainmemory.read_u8(0xCD0+i)11objVisibleX = mainmemory.read_u8(0xB70+i)*25512objVisibleY = mainmemory.read_u8(0xC78+i)*25513objDamage = mainmemory.read_u8(0x1300+i) --how much damage it will do if it collides with you14objHealth = mainmemory.read_u8(0x12A8+i-2) --something is wrong, -2 makes it right in some cases but makes others wrong15objStatus = mainmemory.read_u8(0x1250+i) --collision status16adjustedX = objX - objVisibleX17adjustedY = objY - objVisibleY18--clipping19if(adjustedX > 0 and adjustedY > 0) then20gui.text(21adjustedX * xmult,22adjustedY * ymult,23objX24.. " " .. objY25-- .. " " .. "#" .. i26-- .. " D" .. objDamage27-- .. " HP" .. objHealth28-- .. " S" .. objStatus29)30end31end32end3334function drawHitBoxes()3536for i = 0,88 do3738objX = mainmemory.read_u8(0xBC8+i)39objY = mainmemory.read_u8(0xCD0+i)40objVisibleX = mainmemory.read_u8(0xB70+i)*25541objVisibleY = mainmemory.read_u8(0xC78+i)*25542adjustedX = objX - objVisibleX43adjustedY = objY - objVisibleY44objOffsetX = mainmemory.read_u8(0x1930+i)45objDirection = mainmemory.read_u8(0xAC0+i)46objUnknownY = mainmemory.read_u8(0x19E0+i)47hitSizeX = mainmemory.read_u8(0x1988+i)48hitSizeY = mainmemory.read_u8(0x1A38+i)4950if(objDirection == 1) then --948451objOffsetX = bit.bxor(0xFF,objOffsetX) --948852objOffsetX = objOffsetX+1 --948A53end5455off00 = 0 --942B56if (bit.band(0x80, objOffsetX) == 128) then --942F57of00=bit.band(0xFF,(off00-1)) --943158end5960hitBoxCornerX = bit.band(0xFF,(objX + objOffsetX)) --943461hitBoxCornerY = bit.band(0xFF,(objY + objUnknownY)) --944F6263objStatus = mainmemory.read_u8(0x1250+i)-- generally: 0 inert, 1 benign, 2 damageable/possibly damaging6465if(objStatus == 0) then66fill = 0x600000FF67line = 0xC000000068elseif(objStatus == 1) then69fill = 0x3C00FF0070line = 0x8000FF0071elseif(objStatus == 2) then72fill = 0x50FF000073line = 0x80FF000074end7576--clipping77if(adjustedX > 0 and adjustedY > 0) then78gui.drawBox(79hitBoxCornerX-hitSizeX,80hitBoxCornerY+hitSizeY,81hitBoxCornerX+hitSizeX,82hitBoxCornerY-hitSizeY,83line,84fill85)86end87end88end8990function dispProperties(num)9192fill = 0x80FFC8C89394ObjDamageInfo = {950x13b0,--5 means is being damaged960x1a90,--invulnerability countdown970xf90,--if 0, animate. seems to be used as a counter to temporarily freeze objs when damaged980xb18,--flashing if equal to 0x10, white if equal to 0x86990x1ae8,1000x1f18,1010x11f8,1020x12a8--health103}104105for i = 1,8 do106gui.text((10+(i*20)) * xmult ,100 * ymult, mainmemory.read_u8(ObjDamageInfo[i]+num))107end108109hitBoxInfo = {1100x1988,1110x1A38,1120x1930,1130xAC0114}115116for i = 1,4 do117gui.text((10+(i*20)) * xmult,120 * ymult, mainmemory.read_u8(hitBoxInfo[i]+num))118end119120ObjPositionInfo = {1210xB70, --offscreen or not1220xBC8, --x position1230xC20,1240xC78,1250xCD0, --y position1260xD28,127}128129for i = 1,6 do130gui.text((10+(i*20)) * xmult,140 * ymult, mainmemory.read_u8(ObjPositionInfo[i]+num))131end132133collisionInfo = {1340x710, --compensated x1350x720, --compensated y1360x730 --compensated "visible"137}138139for i = 1,3 do140gui.text((10+(i*20)) * xmult,160 * ymult, mainmemory.read_u8(collisionInfo[i]+num))141end142end143144while true do145--Multiplier for text rendering146xmult = client.screenwidth() / 256147ymult = client.screenheight() / 225148line = 0xFFFFC8C8149--display info about a given object150--dispProperties(0)151152drawHitBoxes()153drawObjInfo()154emu.frameadvance()155--invincibility cheat156-- memory.writebyte(0x13B0, 0)157158end159160--[[ Notes161162--Object Damage163164A1ED LDY $33B0,X ;"can damage"165A1F0 LDA $A26D,Y166A1F3 STA $3A90,X ;invulnerability countdown167A1F6 LDA $A27D,X168A1F9 STA $2F90,X ;whether to animate the obj or not169A1FC LDA $2B18,X ;flashing or not170A1FF STA $3AE8,X171A202 LDA #$86 ;make the palette white172A204 STA $2B18,X173A207 LDA $3F18,X174A20A ORA #$03175A20C STA $31F8,X176A20F LDA $32A8,X177A212 SEC178A213 SBC $00 ;subtract the amount of damage to do179A215 STA $32A8,X ;x is the object slot to modify180181--Where the player's health is decremented182183A1F2 LDA $33B0 ;check if the player is vulnerable184A1F5 BEQ $A234185A1F7 LDA $33B0186A1FA bit.band #$07187A1FC CMP #$05188A1FE BNE $A20B189A200 LDA $36D3190A203 BNE $A20B191A205 STZ $33B0192A20B LDA $98 ;player health193A20D SEC194A20E SBC $32A8 ;subtract amount of damage received195A211 STA $98196197--Where the damage received (32A8) is set1981999546 STA $33B0,X2009549 LDA $33B0201954C BNE $955A202954E LDA $3358,X2039551 STA $33B02049554 LDA $3300,X ;the amount of damage an object will deal to you2059557 STA $32A8206207--Where the hitbox offset is calculated2082099413 LDX #$002109415 LDA $3250,X ;load the hitbox type2119418 BEQ $9460 ;we quit if type 0212941A LDA $3930,X ;x offset213941D STA $01 ;store it in 01214941F LDA $2AC0,X ;direction facing, left is 1, right is 02159422 BEQ $942B ;we are facing...2169424 LDA $01 ;left, load offset2179426 EOR #$FF2189428 INC2199429 STA $01 ;store the altered offset220942B STZ $00221942D LDA $01 ;get the either altered or unaltered offset222942F BPL $94332239431 DEC $002249433 CLC2259434 ADC $2BC8,X ;add x position to either altered or unaltered offset2269437 STA $2710,X ;store that as the hitbox corner227943A LDA $2B70,X ;is the object visible228943D ADC $00 ;correct it depending on the altered x offset229943F STA $2730,X2309442 STZ $002319444 LDA $39E0,X2329447 BPL $944B2339449 DEC $00234944B LDA $2CD0,X ;y position235944E CLC236944F ADC $39E0,X2379452 STA $2720,X ;store hitbox y corner2389455 LDA $2C78,X ;indicator that the object is y visible2399458 ADC $00240945A ORA $2730,X241945D STA $2730,X2429460 INX2439461 CPX #$10 ;we can only do 16 objects2449463 BCC $9415 ;start again if we have objects left2459465 RTS2469466 STZ $33B0,X ;zero the "can damage" byte2479469 LDA $3250,X ;objStatus / collision status248946C BNE $9471 ;if the status is 0 we continue249946E JMP $9507 ;otherwise we quit250251--X and Y represent our two objects2522539471 LDA $3988,X ;x hitbox size2549474 ORA $3A38,X ;y hitbox size2559477 BNE $947C2569479 JMP $9507257947C LDA $3930,X ;x offset258947F STA $012599481 LDA $2AC0,X ;objDirection2609484 BEQ $948D ;branch if we are facing right2619486 LDA $01 ;left2629488 EOR #$FF263948A INC264948B STA $01265948D STZ $00 ;right, zero our temp byte266948F LDA $01 ;load the possibly manipulated offset2679491 BPL $94952689493 DEC $002699495 CLC2709496 ADC $2BC8,X ;add object x position to the possibly manipulated offset2719499 STA $26FF272949C LDA $2B70,X ;objVisibleX273949F ADC $0027494A1 BNE $9507 ;quit if the result is non-zero27594A3 STZ $0027694A5 LDA $39E0,X ;y related27794A8 BPL $94AC27894AA DEC $0027994AC CLC28094AD ADC $2CD0,X ;obj y position28194B0 STA $270028294B3 LDA $2C78,X ;objVisibleY28394B6 ADC $0028494B8 BNE $950728594BA LDA $3250,X ;objStatus / collision status28694BD BPL $94C228794BF CLY28894C0 BRA $94C428994C2 LDY #$0F ;16 objects max29029194C4 LDA $3250,Y ;objStatus / collision status29294C7 BEQ $9504 ;if objStatus is zero, go to the next object29394C9 LDA $2730,Y ;compensated "visible"29494CC BNE $950429594CE LDA $3988,X ;x hitbox size of 1st object29694D1 CLC29794D2 ADC $3988,Y ;x hitbox size of 2nd object29894D5 STA $270129994D8 LDA $3A38,X ;y hitbox size of 1st object30094DB CLC30194DC ADC $3A38,Y ;y hitbox size of 2nd object30294DF STA $270230394E2 LDA $26FF30494E5 SEC30594E6 SBC $2710,Y ;subtract compensated x position for the current object30694E9 BCS $94EE30794EB EOR #$FF30894ED INC30994EE CMP $270131094F1 BCS $950431194F3 LDA $270031294F6 SEC31394F7 SBC $2720,Y ;subtract compensated y position for the current object31494FA BCS $94FF31594FC EOR #$FF31694FE INC31794FF CMP $27023189502 BCC $95083199504 DEY3209505 BPL $94C43219507 RTS322323]]324325