Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- スプライト情報を表示
- require("sdx_common")
- function DrawSpriteRect(x, y, color)
- gui.rect(x - 12, y - 12, x + 11, y + 11, color, color)
- end
- pad, pad_prev = {}
- input_devs, input_devs_prev = {}, {}
- disp_index = 0
- disp_onlyone = false
- accel = 1
- yact_index = 0
- yact_move = 1
- yact_max = 2
- Y_action = yact_index
- MouseActionStat = {
- SelectedSprite = -1
- }
- -- 全スプライトの情報を表示 ----------------------------------------------------
- function DispAllInfo()
- local cx, cy = GetCameraPos()
- local count = 0
- for i = 0, Sprite.Index.max, 1 do
- if Sprite.Exists(i) and (not disp_onlyone or i == disp_index) then
- count = count + 1
- local x, y = Sprite.GetPos(i)
- x = x - cx
- y = y - cy
- DrawSpriteRect(x, y, "#ff000080")
- gui.text(x-12, y-12, i)
- gui.text(x-12, y-4, string.format("%04X", Sprite.GetNumber(i)))
- gui.text(x-12, y+4, string.format("%06X", Sprite.GetProgramAddress(i)))
- end
- end
- end
- -- 操作方法を表示 --------------------------------------------------------------
- function DispHowto()
- local disp_x = 0
- gui.text(disp_x, statusbar_top, "Hold L + R")
- if Y_action == yact_index then gui.text(disp_x, statusbar_top+7, "Y:index")
- elseif Y_action == yact_move then gui.text(disp_x, statusbar_top+7, "Y:move")
- elseif Y_action == yact_map then gui.text(disp_x, statusbar_top+7, "Y:map")
- end
- gui.text(disp_x, statusbar_top+14, "B:"..accel)
- if disp_onlyone
- then gui.text(disp_x, statusbar_top+21, "X:one")
- else gui.text(disp_x, statusbar_top+21, "X:all")
- end
- gui.text(disp_x, statusbar_top+28, "A:retry")
- gui.text(disp_x, statusbar_top+42, string.format("camera:%d, %d", GetCameraPos()))
- end
- --
- function DispUnnamedValue(x, y, adr)
- gui.text(x, y, string.format("$%04X : %04X", adr, memory.readword(adr + disp_index * 2)))
- end
- -- 個別情報を表示 --------------------------------------------------------------
- function DispPersonalInfo()
- local disp_x, disp_x2, disp_x3 = 60, 140, 200
- local disp_y = statusbar_top + 2
- gui.text(disp_x, statusbar_top, "index : "..disp_index)
- if Sprite.Exists(disp_index)
- then gui.text(disp_x, statusbar_top+7, "exist : true")
- else gui.text(disp_x, statusbar_top+7, "exist : false")
- end
- gui.text(disp_x, statusbar_top+14, string.format("num : %04X-%04X", Sprite.GetNumber(disp_index)))
- gui.text(disp_x, statusbar_top+21, string.format("pos : %d, %d", Sprite.GetPos(disp_index)))
- gui.text(disp_x, statusbar_top+28, string.format("program : %06X", Sprite.GetProgramAddress(disp_index)))
- gui.text(disp_x, statusbar_top+35, string.format(" %04X", memory.readword(0x7032 + disp_index *2)))
- gui.text(disp_x, statusbar_top+42, string.format("any : %06X", Sprite.GetAnyAddress(disp_index)))
- DispUnnamedValue(disp_x2, disp_y, 0x6630)
- DispUnnamedValue(disp_x2, disp_y+7, 0x66AA)
- DispUnnamedValue(disp_x2, disp_y+14, 0x6724)
- DispUnnamedValue(disp_x2, disp_y+21, 0x679E)
- DispUnnamedValue(disp_x2, disp_y+28, 0x6818)
- DispUnnamedValue(disp_x2, disp_y+35, 0x6DD0)
- DispUnnamedValue(disp_x2, disp_y+42, 0x6E4A)
- DispUnnamedValue(disp_x3, disp_y, 0x6F3E)
- DispUnnamedValue(disp_x3, disp_y+7, 0x6FB8)
- DispUnnamedValue(disp_x3, disp_y+14, 0x70AC)
- DispUnnamedValue(disp_x3, disp_y+21, 0x7126)
- DispUnnamedValue(disp_x3, disp_y+28, 0x71A0)
- DispUnnamedValue(disp_x3, disp_y+35, 0x721A)
- DispUnnamedValue(disp_x3, disp_y+42, 0x7294)
- end
- -- フレーム前の処理(キー入力に応じて表示を変更) --------------------------------
- function FrameBefore()
- pad_prev = pad
- input_devs_prev = input_devs
- pad = joypad.get(1)
- input_devs = input.get()
- -- マウスイベント処理
- if input_devs.leftclick then
- if not input_devs_prev.leftclick then
- -- 左クリックでスプライトを選択
- MouseActionStat.SelectedSprite = Sprite.Find(input_devs.xmouse, input_devs.ymouse)
- if MouseActionStat.SelectedSprite ~= -1 then
- disp_index = MouseActionStat.SelectedSprite
- end
- else
- -- ドラッグで選択スプライト移動
- local index = MouseActionStat.SelectedSprite
- if Sprite.Exists(index) then
- local cameraX, cameraY = GetCameraPos()
- local worldX, worldY = input_devs.xmouse + cameraX, input_devs.ymouse + cameraY
- Sprite.SetPos(disp_index, worldX, worldY)
- end
- end
- else
- if input_devs_prev.leftclick then
- -- 慣性つきで投げられるとたのしい!
- end
- MouseActionStat.SelectedSprite = -1
- end
- if not pad.L or not pad.R then return end
- if pad.Y and not pad_prev.Y
- then Y_action = Y_action + 1
- if Y_action >= yact_max then Y_action = yact_index end
- end
- if pad.B and not pad_prev.B
- then accel = accel + 1
- if accel > 16 then accel = 1 end
- end
- if pad.X and not pad_prev.X then disp_onlyone = not disp_onlyone end
- if pad.A and not pad_prev.A then SetMapReloadFlag() end
- if Y_action == yact_index then
- -- 対象スプライトを変更
- if pad.right and not pad_prev.right then disp_index = disp_index + 1
- elseif pad.left and not pad_prev.left then disp_index = disp_index - 1
- elseif pad.down and not pad_prev.down then disp_index = disp_index + 10
- elseif pad.up and not pad_prev.up then disp_index = disp_index - 10
- end
- if disp_index < 0 then disp_index = 0
- elseif disp_index > Sprite.Index.max then disp_index = Sprite.Index.max
- end
- elseif Y_action == yact_move then
- -- 対象スプライトを移動
- local x, y = Sprite.GetPos(disp_index)
- if pad.right then x = x + accel
- elseif pad.left then x = x - accel
- end
- if pad.down then y = y + accel
- elseif pad.up then y = y - accel
- end
- Sprite.SetPos(disp_index, x, y)
- end
- pad_prev = pad
- indevs_prev = indevs
- end
- -- フレーム後の処理(キー入力の無効化) ------------------------------------------
- function FrameAfter()
- if not pad.L or not pad.R then return end
- -- ソフトリセット可能にする
- if not pad.start or not pad.select then
- pad.L = false
- pad.R = false
- pad.start = false
- pad.select = false
- end
- pad.up = false
- pad.down = false
- pad.right = false
- pad.left = false
- pad.A = false
- pad.X = false
- pad.Y = false
- pad.B = false
- joypad.set(1, pad)
- end
- -- 描画処理 --------------------------------------------------------------------
- gui.register(function()
- DispAllInfo()
- HideStatusbar()
- DispHowto()
- DispPersonalInfo()
- end)
- -- メインループ ----------------------------------------------------------------
- emu.registerbefore(FrameBefore)
- emu.registerafter(FrameAfter)
Add Comment
Please, Sign In to add comment