Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local TILE_ADDR = 0x00A0
- -- drawing
- local CANVAS_WIDTH = 800
- local CANVAS_HEIGHT = 450
- local ROOM_SIZE = 12
- local ROOM_GAP = 0
- local TILE_SIZE = ROOM_SIZE * 2 + ROOM_GAP * 1
- local X_OFFSET = 6
- local Y_OFFSET = 50
- local draw_POS = {
- [1] = { x = 0, y = 0 },
- [2] = { x = 1, y = 0 },
- [3] = { x = 0, y = 1 },
- [4] = { x = 1, y = 1 }
- }
- -- colors
- local HM = 0xC0B8A8 -- houses
- local HC = 0xA89868 -- hyrule castle
- local AT = HC -- aga's tower
- local EX = 0x706890 -- escape
- local SY = 0x204020 -- sanctuary
- local CV = 0x684830 -- caves
- local EP = 0x80A870 -- eastern palace
- local DP = 0x807838 -- desert palace
- local TH = 0x987870 -- tower of hera
- local PD = 0x909090 -- palace of darkness
- local SP = 0x7890F8 -- swamp palace
- local SW = 0x605030 -- skull woods
- local TT = 0x787888 -- thieves town
- local IP = 0xA8E0E8 -- ice palace
- local MM = 0x408068 -- misery mire
- local TR = 0x583028 -- turtle rock
- local GT = 0xA09058 -- ganon's tower
- local GE = 0x984848 -- empty gt TILEs
- local EM = 0x606060 -- empty TILEs
- local COMPLETE = 0xFFFF0000
- local VISITED = 0xFFFFFF00
- local UNVISITED = 0xFFAAAAAA
- local CURRENT = 0xFF00FFFF
- local BLACK = 0xFF000000
- local WHITE = 0xFFFFFFFF
- local OPAQUE = 0xFF000000
- local TRANS = 0x99000000
- local COLL = 0xFF505050
- local SEMI = 0xF0909090
- local CHEST = 0xFFDEB429
- local MINIMAP_X = 266
- local MINIMAP_Y = 5
- local MINIMAP_SCALE = 3
- local function get_color(color, opacity)
- return bit.bor(color, opacity)
- end -- end get_color
- -- room number from quadrant variables
- local R1, R2, R3, R4 = 1, 2, 3, 4
- local TILES_TO_VALS = {
- ['RX'] = {
- R1 = { A9 = 0x00, AA = 0x00 },
- R2 = { A9 = 0x01, AA = 0x00 },
- R3 = { A9 = 0x00, AA = 0x02 },
- R4 = { A9 = 0x01, AA = 0x02 }
- },
- ['A9AA'] = {
- [0x00] = {
- [0x00] = R1,
- [0x02] = R3
- },
- [0x01] = {
- [0x00] = R2,
- [0x02] = R4
- }
- }
- }
- local function stop_running()
- running = false
- end
- local function end_thing()
- client.SetGameExtraPadding(0, 0, 0, 0)
- stop_running()
- end
- local function initialize()
- running = true
- memory.usememorydomain("WRAM")
- client.SetGameExtraPadding(0, 0, 230, 0)
- the_canvas = gui
- event.onexit(end_thing)
- end
- --[==[
- Format:
- [0x##] = { -- room id
- c = XX -- color
- p = AABA -- room pattern
- r = { p } -- pattern as table
- v = 0100 -- rooms reachable without glitches
- x = { v } -- reachability as table; no dupes
- }
- ]==]
- local TILE_DATA = {
- [0x00] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x01] = { c = HC, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x02] = { c = SY, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x03] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x04] = { c = TR, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x05] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x06] = { c = SP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x07] = { c = TH, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x08] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x09] = { c = PD, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0A] = { c = PD, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x0B] = { c = PD, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0C] = { c = GT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x0D] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0E] = { c = IP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x0F] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x10] = { c = GT, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x11] = { c = EX, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x12] = { c = SY, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x13] = { c = TR, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x14] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x15] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x16] = { c = SP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x17] = { c = TH, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x18] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x19] = { c = PD, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x1A] = { c = PD, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x1B] = { c = PD, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x1C] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x1D] = { c = GT, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x1E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x1F] = { c = IP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x20] = { c = AT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x21] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x22] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x23] = { c = TR, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x24] = { c = TR, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x25] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x26] = { c = SP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x27] = { c = TH, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x28] = { c = SP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x29] = { c = SW, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x2A] = { c = PD, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x2B] = { c = PD, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x2C] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x2D] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x2E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x2F] = { c = CV, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x30] = { c = AT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x31] = { c = TH, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x32] = { c = EX, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x33] = { c = DP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x34] = { c = SP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x35] = { c = SP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x36] = { c = SP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x37] = { c = SP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x38] = { c = SP, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x39] = { c = SW, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x3A] = { c = PD, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x3B] = { c = PD, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x3C] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x3D] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x3E] = { c = IP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x3F] = { c = IP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x40] = { c = AT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x41] = { c = HC, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x42] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x43] = { c = DP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x44] = { c = TT, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x45] = { c = TT, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x46] = { c = SP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x47] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x48] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x49] = { c = SW, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x4A] = { c = PD, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x4B] = { c = PD, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x4C] = { c = GT, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x4D] = { c = GT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x4E] = { c = IP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x4F] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x50] = { c = HC, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x51] = { c = HC, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x52] = { c = HC, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x53] = { c = DP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x54] = { c = SP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x55] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x56] = { c = SW, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x57] = { c = SW, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x58] = { c = SW, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x59] = { c = SW, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x5A] = { c = PD, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x5B] = { c = GT, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x5C] = { c = GT, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x5D] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x5E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x5F] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x60] = { c = HC, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x61] = { c = HC, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x62] = { c = HC, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x63] = { c = DP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x64] = { c = TT, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x65] = { c = TT, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x66] = { c = SP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x67] = { c = SW, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x68] = { c = SW, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x69] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x6A] = { c = PD, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x6B] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x6C] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x6D] = { c = GT, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x6E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x6F] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x70] = { c = EX, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x71] = { c = EX, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x72] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x73] = { c = DP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x74] = { c = DP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x75] = { c = DP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x76] = { c = SP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x77] = { c = TH, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x78] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x79] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x7A] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x7B] = { c = GT, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x7C] = { c = GT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x7D] = { c = GT, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x7E] = { c = IP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x7F] = { c = IP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x80] = { c = EX, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x81] = { c = EX, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x82] = { c = EX, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x83] = { c = DP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x84] = { c = DP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x85] = { c = DP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x86] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x87] = { c = TH, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x88] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x89] = { c = EP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x8A] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x8B] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x8C] = { c = GT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x8D] = { c = GT, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x8E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x8F] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x90] = { c = MM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x91] = { c = MM, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x92] = { c = MM, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x93] = { c = MM, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x94] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x95] = { c = GT, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x96] = { c = GT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x97] = { c = MM, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x98] = { c = MM, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x99] = { c = EP, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x9A] = { c = GE, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x9B] = { c = GT, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x9C] = { c = GT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x9D] = { c = GT, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0x9E] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x9F] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xA0] = { c = MM, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0xA1] = { c = MM, p = 'AABA', r = { 'A', 'A', 'B', 'A' } },
- [0xA2] = { c = MM, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xA3] = { c = MM, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xA4] = { c = TR, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xA5] = { c = GT, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0xA6] = { c = GT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xA7] = { c = TH, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0xA8] = { c = EP, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0xA9] = { c = EP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xAA] = { c = EP, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xAB] = { c = TT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xAC] = { c = TT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xAD] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xAE] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xAF] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xB0] = { c = AT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xB1] = { c = MM, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0xB2] = { c = MM, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0xB3] = { c = MM, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0xB4] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xB5] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xB6] = { c = TR, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xB7] = { c = TR, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xB8] = { c = EP, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xB9] = { c = EP, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xBA] = { c = EP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xBB] = { c = TT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xBC] = { c = TT, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0xBD] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xBE] = { c = IP, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xBF] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xC0] = { c = AT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xC1] = { c = MM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xC2] = { c = MM, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xC3] = { c = MM, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xC4] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xC5] = { c = TR, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xC6] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xC7] = { c = TR, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xC8] = { c = EP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xC9] = { c = EP, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0xCA] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xCB] = { c = TT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xCC] = { c = TT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xCD] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xCE] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xCF] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xD0] = { c = AT, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xD1] = { c = MM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xD2] = { c = MM, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xD3] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xD4] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xD5] = { c = TR, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xD6] = { c = TR, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xD7] = { c = EM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xD8] = { c = EP, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0xD9] = { c = EP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0xDA] = { c = EP, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0xDB] = { c = TT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xDC] = { c = TT, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xDD] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xDE] = { c = IP, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xDF] = { c = CV, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0xE0] = { c = AT, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xE1] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xE2] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xE3] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xE4] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xE5] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xE6] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xE7] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xE8] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xE9] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xEA] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xEB] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xEC] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xED] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xEE] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xEF] = { c = CV, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- [0xF0] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xF1] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xF2] = { c = HM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF3] = { c = HM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF4] = { c = HM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF5] = { c = HM, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF6] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF7] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xF8] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xF9] = { c = CV, p = 'ABBB', r = { 'A', 'B', 'B', 'B' } },
- [0xFA] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0xFB] = { c = CV, p = 'ABBB', r = { 'A', 'B', 'B', 'B' } },
- [0xFC] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0xFD] = { c = CV, p = 'ABAA', r = { 'A', 'B', 'A', 'A' } },
- [0xFE] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0xFF] = { c = CV, p = 'ABCC', r = { 'A', 'B', 'C', 'C' } },
- -- underworld 2
- [0x0100] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0101] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0102] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0103] = { c = CV, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x0104] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0105] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0106] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0107] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0108] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0109] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x010A] = { c = CV, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x010B] = { c = CV, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x010C] = { c = CV, p = 'ABCB', r = { 'A', 'B', 'C', 'B' } },
- [0x010D] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x010E] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x010F] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0110] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0111] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0112] = { c = CV, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x0113] = { c = CV, p = 'ABAB', r = { 'A', 'B', 'A', 'B' } },
- [0x0114] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0115] = { c = CV, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x0116] = { c = CV, p = 'AABC', r = { 'A', 'A', 'B', 'C' } },
- [0x0117] = { c = CV, p = 'AAAA', r = { 'A', 'A', 'A', 'A' } },
- [0x0118] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0119] = { c = CV, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x011A] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x011B] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x011C] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x011D] = { c = CV, p = 'AABB', r = { 'A', 'A', 'B', 'B' } },
- [0x011E] = { c = CV, p = 'ABAC', r = { 'A', 'B', 'A', 'C' } },
- [0x011F] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0120] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0121] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0122] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0123] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0124] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0125] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0126] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- [0x0127] = { c = CV, p = 'ABCD', r = { 'A', 'B', 'C', 'D' } },
- }
- -- room tracking
- local prev = nil
- local prev_quad = nil
- local check_map = false
- -- drawing
- local function draw_tile(tile, quad_id)
- if tile == nil then return end
- local x = (bit.band(tile, 0x0F) * TILE_SIZE + 1) + X_OFFSET
- local y = ((bit.band(tile, 0xF0) / 16) * TILE_SIZE + 1) + Y_OFFSET
- the_canvas.drawRectangle(x, y, TILE_SIZE, TILE_SIZE, BLACK, BLACK) -- clear only this section
- local d = TILE_DATA[tile]
- local r = d.r
- local room_completion_colors = { 0, 0, 0, 0 }
- for i=1, 4 do
- room_completion_colors[i] =
- quad_id == TILE_DATA[tile].r[i] and CURRENT
- or UNVISITED and OPAQUE or TRANS
- the_canvas.drawRectangle(
- x + (ROOM_SIZE) * draw_POS[i].x,
- y + (ROOM_SIZE) * draw_POS[i].y,
- ROOM_SIZE,
- ROOM_SIZE,
- nil,
- room_completion_colors[i]
- )
- if TILE_DATA[tile].x[r[i]] == 0 then
- --[[the_canvas.drawText(
- x + (ROOM_SIZE) * draw_POS[i].x + 1,
- y + (ROOM_SIZE) * draw_POS[i].y - 1,
- "X",
- 0x55FFFFFF,
- 0
- )]]
- end
- end
- local C0
- if quad_id then
- C0 = CURRENT
- else
- C0 = UNVISITED
- end
- -- vertical separators
- local C1 = r[1] == r[2] and room_completion_colors[1] or C0
- local C2 = r[3] == r[4] and room_completion_colors[3] or C0
- the_canvas.drawLine(x + ROOM_SIZE + ROOM_GAP, y + ROOM_GAP,
- x + ROOM_SIZE + ROOM_GAP, y + ROOM_SIZE,
- C1)
- the_canvas.drawLine(x + ROOM_GAP + ROOM_SIZE, y + ROOM_GAP + ROOM_GAP + ROOM_SIZE,
- x + ROOM_GAP + ROOM_SIZE, y + ROOM_SIZE + ROOM_SIZE,
- C2)
- -- horizontal separators
- local C3 = r[1] == r[3] and room_completion_colors[1] or C0
- local C4 = r[2] == r[4] and room_completion_colors[2] or C0
- the_canvas.drawLine(x + ROOM_GAP + ROOM_GAP, y + ROOM_GAP + ROOM_SIZE,
- x + ROOM_SIZE, y + ROOM_GAP + ROOM_SIZE,
- C3)
- the_canvas.drawLine(x + ROOM_GAP + ROOM_GAP + ROOM_SIZE, y + ROOM_GAP + ROOM_SIZE,
- x + ROOM_SIZE + ROOM_SIZE, y + ROOM_GAP + ROOM_SIZE,
- C4)
- local C5 = d.p == 'AAAA' and C1 or C0
- the_canvas.drawPixel(x + ROOM_GAP + ROOM_SIZE, y + ROOM_GAP + ROOM_SIZE, BLACK)
- the_canvas.drawPixel(x + ROOM_GAP + ROOM_SIZE, y + ROOM_GAP + ROOM_SIZE, C5)
- the_canvas.drawRectangle(x, y, TILE_SIZE, TILE_SIZE, C0, nil)
- end -- end draw_tile
- local function draw_all()
- the_canvas.Clear(BLACK)
- for i=0, 0x0127 do
- draw_tile(i)
- end
- --the_canvas.refresh()
- end -- end draw_all
- local NONE = nil
- local NOTHING = 0xFF777777
- local TURF = 0xFF4A9C4A
- local COLL = 0xFF282828
- local SEMI = 0xFF303030
- local CHEST = 0xFFDEB429
- local RAIL = 0xFF707070
- local SPIKE = 0xFFE0E0E0
- local POT = 0xFF7B4A4A
- local BUSH = 0xFF317331
- local WATER = 0xFF3962AC
- local SHALLOW_WATER = 0xFF5A83C5
- local THICK_GRASS = 0xFF115511
- local SPIKE_FLOOR = 0xFFA4A4A4
- local PIT = 0xFF550000
- local CRACKED = 0xFF330000
- local AUTO_STAIRS = 0xFF6A4A31
- local MANUAL_STAIRS = 0xFF8A6A51
- local ROOM_STAIRS = 0xFF5A737B
- local PEGS_1 = 0xFF414183
- local PEGS_2 = 0xFF6A6AC5
- local LIGHT_ROCK = 0xFF7BBD94
- local DARK_ROCK = 0xFF528373
- local RUPEES = 0xFF626283
- local SOM_LINE = 0xFFEEEEEE
- local SOM_LINE_Q = 0xFF7B4A4A
- local TORCH = 0xFFA4A4A4
- local CONVEYOR = 0xFF627362
- local SIGN = 0xFF8B7341
- local STAR = 0xFFAC7B52
- local KEY_DOOR = 0xFFAC9C6A
- local collision_map = {
- [0x00] = NOTHING,
- [0x01] = COLL,
- [0x02] = COLL,
- [0x03] = COLL,
- [0x04] = COLL,
- [0x05] = nil,
- [0x06] = nil,
- [0x07] = nil,
- [0x08] = WATER,
- [0x09] = SHALLOW_WATER,
- [0x0A] = nil,
- [0x0B] = COLL,
- [0x0C] = nil,
- [0x0D] = SPIKE_FLOOR,
- [0x0E] = SEMI,
- [0x0F] = SEMI,
- [0x10] = SEMI,
- [0x11] = SEMI,
- [0x12] = SEMI,
- [0x13] = SEMI,
- [0x14] = SEMI,
- [0x15] = SEMI,
- [0x16] = SEMI,
- [0x17] = SEMI,
- [0x18] = SEMI,
- [0x19] = SEMI,
- [0x1A] = SEMI,
- [0x1B] = SEMI,
- [0x1C] = AUTO_STAIRS, -- stairs?
- [0x1D] = AUTO_STAIRS,
- [0x1E] = AUTO_STAIRS,
- [0x1F] = AUTO_STAIRS,
- [0x20] = PIT,
- [0x21] = nil,
- [0x22] = MANUAL_STAIRS,
- [0x23] = nil,
- [0x24] = nil,
- [0x25] = nil,
- [0x26] = COLL,
- [0x27] = COLL,
- [0x28] = SEMI,
- [0x29] = SEMI,
- [0x2A] = SEMI,
- [0x2B] = SEMI,
- [0x2C] = SEMI,
- [0x2D] = SEMI,
- [0x2E] = SEMI,
- [0x2F] = SEMI,
- [0x30] = ROOM_STAIRS,
- [0x31] = ROOM_STAIRS,
- [0x32] = ROOM_STAIRS,
- [0x33] = ROOM_STAIRS,
- [0x34] = ROOM_STAIRS,
- [0x35] = ROOM_STAIRS,
- [0x36] = ROOM_STAIRS,
- [0x37] = ROOM_STAIRS,
- [0x38] = ROOM_STAIRS,
- [0x39] = ROOM_STAIRS,
- [0x3A] = STAR,
- [0x3B] = STAR,
- [0x3C] = nil,
- [0x3D] = AUTO_STAIRS,
- [0x3E] = AUTO_STAIRS,
- [0x3F] = AUTO_STAIRS,
- [0x40] = THICK_GRASS,
- [0x41] = nil,
- [0x42] = COLL,
- [0x43] = COLL,
- [0x44] = SPIKE,
- [0x45] = nil,
- [0x46] = COLL,
- [0x47] = nil,
- [0x48] = TURF,
- [0x49] = nil,
- [0x4A] = nil,
- [0x4B] = nil,
- [0x4C] = nil,
- [0x4D] = nil,
- [0x4E] = COLL,
- [0x4F] = COLL,
- [0x50] = BUSH,
- [0x51] = BUSH,
- [0x52] = LIGHT_ROCK,
- [0x53] = DARK_ROCK,
- [0x54] = SIGN,
- [0x55] = LIGHT_ROCK,
- [0x56] = DARK_ROCK,
- [0x57] = COLL,
- [0x58] = CHEST,
- [0x59] = CHEST,
- [0x5A] = CHEST,
- [0x5B] = CHEST,
- [0x5C] = CHEST,
- [0x5D] = CHEST,
- [0x5E] = ROOM_STAIRS,
- [0x5F] = nil,
- [0x60] = RUPEES,
- [0x61] = nil,
- [0x62] = CRACKED,
- [0x63] = CHEST,
- [0x64] = nil,
- [0x65] = nil,
- [0x66] = PEGS_1,
- [0x67] = PEGS_2,
- [0x68] = CONVEYOR,
- [0x69] = CONVEYOR,
- [0x6A] = CONVEYOR,
- [0x6B] = CONVEYOR,
- [0x6C] = COLL,
- [0x6D] = COLL,
- [0x6E] = COLL,
- [0x6F] = COLL,
- [0x70] = POT,
- [0x71] = POT,
- [0x72] = POT,
- [0x73] = POT,
- [0x74] = POT,
- [0x75] = POT,
- [0x76] = POT,
- [0x77] = POT,
- [0x78] = POT,
- [0x79] = POT,
- [0x7A] = POT,
- [0x7B] = POT,
- [0x7C] = POT,
- [0x7D] = POT,
- [0x7E] = POT,
- [0x7F] = POT,
- [0x80] = ROOM_STAIRS,
- [0x81] = ROOM_STAIRS,
- [0x82] = ROOM_STAIRS,
- [0x83] = ROOM_STAIRS,
- [0x84] = ROOM_STAIRS,
- [0x85] = ROOM_STAIRS,
- [0x86] = ROOM_STAIRS,
- [0x87] = ROOM_STAIRS,
- [0x88] = ROOM_STAIRS,
- [0x89] = ROOM_STAIRS,
- [0x8A] = ROOM_STAIRS,
- [0x8B] = ROOM_STAIRS,
- [0x8C] = ROOM_STAIRS,
- [0x8D] = ROOM_STAIRS,
- [0x8E] = ROOM_STAIRS,
- [0x8F] = ROOM_STAIRS,
- [0x90] = nil,
- [0x91] = nil,
- [0x92] = nil,
- [0x93] = nil,
- [0x94] = nil,
- [0x95] = nil,
- [0x96] = nil,
- [0x97] = nil,
- [0x98] = nil,
- [0x99] = nil,
- [0x9A] = nil,
- [0x9B] = nil,
- [0x9C] = nil,
- [0x9D] = nil,
- [0x9E] = nil,
- [0x9F] = nil,
- [0xA0] = nil,
- [0xA1] = nil,
- [0xA2] = nil,
- [0xA3] = nil,
- [0xA4] = nil,
- [0xA5] = nil,
- [0xA6] = nil,
- [0xA7] = nil,
- [0xA8] = nil,
- [0xA9] = nil,
- [0xAA] = nil,
- [0xAB] = nil,
- [0xAC] = nil,
- [0xAD] = nil,
- [0xAE] = nil,
- [0xAF] = nil,
- [0xB0] = SOM_LINE,
- [0xB1] = SOM_LINE,
- [0xB2] = SOM_LINE,
- [0xB3] = SOM_LINE,
- [0xB4] = SOM_LINE,
- [0xB5] = SOM_LINE,
- [0xB6] = SOM_LINE_Q,
- [0xB7] = nil,
- [0xB8] = nil,
- [0xB9] = nil,
- [0xBA] = nil,
- [0xBB] = nil,
- [0xBC] = nil,
- [0xBD] = SOM_LINE,
- [0xBE] = AUTO_STAIRS,
- [0xBF] = nil,
- [0xC0] = TORCH,
- [0xC1] = TORCH,
- [0xC2] = TORCH,
- [0xC3] = TORCH,
- [0xC4] = TORCH,
- [0xC5] = TORCH,
- [0xC6] = TORCH,
- [0xC7] = TORCH,
- [0xC8] = TORCH,
- [0xC9] = TORCH,
- [0xCA] = TORCH,
- [0xCB] = TORCH,
- [0xCC] = TORCH,
- [0xCD] = TORCH,
- [0xCE] = TORCH,
- [0xCF] = TORCH,
- [0xD0] = nil,
- [0xD1] = nil,
- [0xD2] = nil,
- [0xD3] = nil,
- [0xD4] = nil,
- [0xD5] = nil,
- [0xD6] = nil,
- [0xD7] = nil,
- [0xD8] = nil,
- [0xD9] = nil,
- [0xDA] = nil,
- [0xDB] = nil,
- [0xDC] = nil,
- [0xDD] = nil,
- [0xDE] = nil,
- [0xDF] = nil,
- [0xE0] = nil,
- [0xE1] = nil,
- [0xE2] = nil,
- [0xE3] = nil,
- [0xE4] = nil,
- [0xE5] = nil,
- [0xE6] = nil,
- [0xE7] = nil,
- [0xE8] = AUTO_STAIRS,
- [0xE9] = nil,
- [0xEA] = nil,
- [0xEB] = nil,
- [0xEC] = nil,
- [0xED] = nil,
- [0xEE] = nil,
- [0xEF] = nil,
- [0xF0] = KEY_DOOR,
- [0xF1] = KEY_DOOR,
- [0xF2] = KEY_DOOR,
- [0xF3] = KEY_DOOR,
- [0xF4] = COLL,
- [0xF5] = COLL,
- [0xF6] = COLL,
- [0xF7] = COLL,
- [0xF8] = COLL,
- [0xF9] = COLL,
- [0xFA] = COLL,
- [0xFB] = COLL,
- [0xFC] = COLL,
- [0xFD] = COLL,
- [0xFE] = COLL,
- [0xFF] = COLL
- }
- local function in_overworld()
- return memory.readbyte(0x001B) == 0
- end
- local tile_shit = {}
- local ow = true
- local owm = -1
- local owmy, owmx
- local uwm = -1
- local mod_factor = 0x200
- local scale_factor = 2
- local scale_factor_tile = 8
- local MAP_OFFSET_BASE_X = 128
- local MAP_OFFSET_BASE_Y = 108
- local map_offset_x = MAP_OFFSET_BASE_X
- local map_offset_y = MAP_OFFSET_BASE_Y
- for x = 0, 63 do
- tile_shit[x] = {}
- for y = 0, 63 do
- tile_shit[x][y] = 0
- end
- end
- local function get_uw_tile(y, x, tilemap_mask, layer)
- local tile_idx = y * 64 + x + (layer == 1 and 0x1000 or 0x0000)
- return memory.read_u8(0x12000 + tile_idx)
- end
- local function get_ow_tile(y, x)
- local tile1_idx = (y * 64 + x) * 2
- local tile1 = bit.lshift(memory.read_u16_le(0x2000 + tile1_idx), 2)
- local tile2_idx = bit.lshift(bit.bor(tile1, bit.band(x, 1)), 1)
- local tile2 = memory.read_u16_le(0x0F8000 + tile2_idx, "System Bus")
- local tile3_idx = bit.band(tile2, 0x1FF)
- local tile3 = memory.read_u16_le(0x0FFD94 + tile3_idx, "System Bus")
- if tile3 >= 0x10 and tile3 < 0x1C then
- tile3 = bit.bor(bit.rol(bit.lshift(bit.band(tile3, 0x40), 1), 2), tile3)
- end
- return bit.band(tile3, 0xFF)
- end
- local big_ow_screens = {
- [0x00] = true,
- [0x03] = true,
- [0x05] = true,
- [0x18] = true,
- [0x1B] = true,
- [0x1E] = true,
- [0x2A] = true,
- [0x30] = true,
- [0x35] = true,
- [0x40] = true,
- [0x43] = true,
- [0x45] = true,
- [0x58] = true,
- [0x5B] = true,
- [0x5E] = true,
- [0x6A] = true,
- [0x70] = true,
- [0x75] = true
- }
- local function get_all_tiles()
- --print('get_all_tiles')
- ow = in_overworld()
- if ow then
- owm = memory.read_u8(0x8A)
- owmx = bit.band(owm, 1) == 1
- owmy = bit.band(math.floor(owm / 8), 1) == 1
- else
- uwm = memory.read_u8(0xA0)
- end
- local layer = memory.read_u16_le(0x00EE)
- local tilemap_mask = memory.read_u16_le(0x00EC)
- mod_factor = (ow) and 0x400 or 0x200
- scale_factor = (ow) and 1 or 2
- scale_factor_tile = (ow) and 16 or 8
- map_offset_x = math.floor(MAP_OFFSET_BASE_X * MINIMAP_SCALE / scale_factor_tile)
- map_offset_y = math.floor(MAP_OFFSET_BASE_Y * MINIMAP_SCALE / scale_factor_tile)
- for y = 0, 63 do
- for x = 0, 63 do
- local tile
- if ow then
- tile = get_ow_tile(y, x, tilemap_mask)
- else
- tile = get_uw_tile(y, x, tilemap_mask, layer)
- end
- tile_shit[x][y] = tile
- end
- end
- end
- local got_map = false
- local function draw_minimap()
- --the_canvas.drawRectangle(MINIMAP_X-10, MINIMAP_Y-10, MINIMAP_SCALE * 80, MINIMAP_SCALE * 80, BLACK, BLACK)
- the_canvas.drawRectangle(MINIMAP_X-1, MINIMAP_Y-1, MINIMAP_SCALE*64+2, MINIMAP_SCALE*64+2, COMPLETE, BLACK)
- for y = 0, 63 do
- for x = 0, 63 do
- local tile = tile_shit[x][y]
- tile = collision_map[tile]
- if tile then
- the_canvas.drawRectangle(MINIMAP_X + x * MINIMAP_SCALE,
- MINIMAP_Y + y * MINIMAP_SCALE,
- MINIMAP_SCALE,
- MINIMAP_SCALE,
- tile - 0xAA000000,
- tile)
- end
- end
- end
- local linky = memory.read_u16_le(0x20)
- local linkx = memory.read_u16_le(0x22)
- local cameray = memory.read_u16_le(0x618)
- local camerax = memory.read_u16_le(0x61C)
- linky = linky % mod_factor
- linkx = linkx % mod_factor
- cameray = cameray % mod_factor
- camerax = camerax % mod_factor
- if ow then
- if owmx then
- linkx = bit.band(linkx + 0x200, 0x3FF)
- camerax = bit.band(camerax + 0x200, 0x3FF)
- end
- if owmy then
- linky = bit.band(linky + 0x200, 0x3FF)
- cameray = bit.band(cameray + 0x200, 0x3FF)
- end
- end
- linky = math.floor(linky * MINIMAP_SCALE / scale_factor_tile)
- linkx = math.floor(linkx * MINIMAP_SCALE / scale_factor_tile)
- cameray = math.floor(cameray * MINIMAP_SCALE / scale_factor_tile)
- camerax = math.floor(camerax * MINIMAP_SCALE / scale_factor_tile)
- the_canvas.drawRectangle(MINIMAP_X + camerax - map_offset_x, MINIMAP_Y + cameray - map_offset_y, 256 / scale_factor_tile * MINIMAP_SCALE, 236 / scale_factor_tile * MINIMAP_SCALE, CURRENT)
- the_canvas.drawRectangle(MINIMAP_X + linkx, MINIMAP_Y + linky + MINIMAP_SCALE, MINIMAP_SCALE * scale_factor, MINIMAP_SCALE * scale_factor, VISITED)
- end
- local modes_to_ignore = {
- [0x7FBF] = true,
- [0x0000] = true,
- [0x0001] = true,
- [0x0002] = true,
- [0x0003] = true,
- [0x0004] = true,
- [0x0005] = true,
- [0x0006] = true,
- [0x0007] = true,
- [0x0008] = true,
- [0x0008] = true,
- [0x0008] = true,
- [0x0008] = true,
- [0x0009] = true,
- [0x0100] = true,
- [0x0101] = true,
- [0x0102] = true,
- [0x0103] = true,
- [0x0104] = true,
- [0x0105] = true,
- [0x0105] = true,
- [0x0400] = true,
- [0x0401] = true,
- [0x0402] = true,
- [0x0403] = true,
- [0x0500] = true,
- [0x1701] = true,
- [0x1702] = true,
- [0x0500] = true,
- [0x1B02] = true
- }
- local active_link_modes = {
- [0x0700] = true,
- [0x0900] = true,
- [0x0B00] = true,
- }
- local refresh_map_modes = {
- [0x0703] = true,
- [0x0704] = true,
- [0x0705] = true,
- [0x0708] = true,
- [0x0709] = true,
- [0x070B] = true,
- [0x070C] = true,
- [0x070D] = true,
- [0x0710] = true,
- [0x0716] = true,
- [0x0717] = true,
- [0x071A] = true,
- }
- local function do_main()
- local last = nil
- while running do
- emu.frameadvance()
- local gamemode = memory.read_u16_be(0x0010)
- local current = tostring(in_overworld()) .. '-' .. tostring(memory.read_u8(in_overworld() and 0x8A or 0xA0))
- if current ~= last or refresh_map_modes[gamemode] then
- -- get new map when changing screen
- got_map = false
- last = current
- end
- if not got_map and active_link_modes[gamemode] then
- -- redraw map once we know
- get_all_tiles()
- got_map = true
- end
- if not modes_to_ignore[gamemode] then
- draw_minimap()
- end
- end
- --[[
- local ow_flag = memory.readbyte(0x001B)
- if not (ow_flag == 0x01) then
- if check_map and prev ~= nil then
- draw_tile(prev)
- prev = nil
- end
- check_map = false
- else
- if memory.readbyte(0x0010) == 0x07 then
- check_map = true
- else
- check_map = false
- draw_tile(prev)
- prev = nil
- end
- end
- if check_map then
- local tile = memory.readbyte(TILE_ADDR)
- local A9 = memory.readbyte(0xA9)
- local AA = memory.readbyte(0xAA)
- local quadrant = TILES_TO_VALS.A9AA[A9][AA]
- local quad_id = TILE_DATA[tile].r[quadrant]
- if quadrant ~= prev_quad or tile ~= prev then
- prev_quad = quadrant
- end
- draw_tile(tile, quad_id)
- if tile ~= prev then
- draw_tile(prev)
- prev = tile
- end
- end
- --]]
- end
- initialize()
- --draw_all()
- --get_all_tiles()
- event.onloadstate(get_all_tiles)
- do_main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement