[jak 2] bigmap, fix texture filtering on map icons (#2906)

![image](https://github.com/open-goal/jak-project/assets/48171810/4c285f31-c874-424a-8510-d181ba0f88d5)


![image](https://github.com/open-goal/jak-project/assets/48171810/6baa29ef-df92-435e-ad2f-9a42d56e6f17)

and the minimap has filtering now:

![image](https://github.com/open-goal/jak-project/assets/48171810/7cb2b0c9-5c86-426e-b028-dddcc3d649f7)

It's mostly implemented in C++ using the texture animator.
This commit is contained in:
water111
2023-08-15 21:53:06 -04:00
committed by GitHub
parent 5343b5172e
commit 0c5e01643e
20 changed files with 426 additions and 224 deletions
+16 -16
View File
@@ -7882,23 +7882,23 @@
(new (symbol type) _type_ 0)
(initialize (_type_) none 9) ;; some sort of init?
(update (_type_) none 10)
(bigmap-method-11 (_type_ int int int int) int 11)
(bigmap-method-12 (_type_) int 12)
(bigmap-method-13 (_type_) int 13)
(bigmap-method-14 (_type_) none 14)
(bigmap-method-15 (_type_) int 15)
(draw (_type_ int int int int) int 11)
(handle-cpad-inputs (_type_) int 12)
(compress-all (_type_) int 13)
(enable-drawing (_type_) none 14)
(disable-drawing (_type_) int 15)
(dump-to-file (_type_) file-stream 16)
(bigmap-method-17 (_type_ vector) int 17)
(bigmap-method-18 (_type_) int 18)
(bigmap-method-19 (_type_) int 19)
(bigmap-method-20 (_type_) int 20)
(bigmap-method-21 (_type_ int int) int 21)
(bigmap-method-22 (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(bigmap-method-23 (_type_) none 23)
(bigmap-method-24 (_type_ dma-buffer) none 24)
(bigmap-method-25 (_type_ dma-buffer) none 25)
(bigmap-method-26 (_type_ dma-buffer int int int int) none 26)
(bigmap-method-27 (_type_ dma-buffer connection-minimap) int 27)
(set-pos! (_type_ vector) int 17)
(decompress-current-masks! (_type_) int 18)
(compress-current-masks! (_type_) int 19)
(set-enable-from-position! (_type_) int 20)
(maybe-fill-for-position (_type_ int int) int 21)
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(mask-image-from-bit-mask (_type_) none 23)
(draw-non-city-map (_type_ dma-buffer) none 24)
(draw-city-map (_type_ dma-buffer) none 25)
(sprite-dma (_type_ dma-buffer int int int int) none 26)
(draw-from-minimap (_type_ dma-buffer connection-minimap) int 27)
)
)
@@ -4361,5 +4361,24 @@
"vars": {
"v0-0": ["tex", "texture-id"]
}
},
"(method 18 bigmap)" : {
"vars": {
"s5-0": "compressed-mask-data",
"a0-2": "decompressed-data-end",
"v1-7": "decompressed-size",
"a1-3": "bytes-to-shift-back",
"a2-2": "byte-idx",
"a0-5": "layer-idx",
"a1-6" : "layer-data",
"v1-10": "data",
"a0-9": "qw-idx"
}
},
"(method 19 bigmap)": {
"vars": {
"s5-0": "compressed-data-dest",
"v1-4": "compressed-data-size"
}
}
}
@@ -189,6 +189,17 @@ float u32_to_sc(u32 in) {
return (flt - 0.5) * 16.0;
}
void DirectRenderer::lookup_textures_again(SharedRenderState* render_state) {
for (int i = 0; i < TEXTURE_STATE_COUNT; i++) {
if (m_buffered_tex_state_currently_bound[i]) {
auto& tex_state = m_buffered_tex_state[i];
tex_state.used = true;
update_gl_texture(render_state, i);
tex_state.used = false;
}
}
}
void DirectRenderer::flush_pending(SharedRenderState* render_state, ScopedProfilerNode& prof) {
// update opengl state
if (m_blend_state_needs_gl_update) {
@@ -211,6 +222,9 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state, ScopedProfil
if (tex_state.used) {
update_gl_texture(render_state, i);
tex_state.used = false;
m_buffered_tex_state_currently_bound[i] = true;
} else {
m_buffered_tex_state_currently_bound[i] = false;
}
}
m_next_free_tex_state = 0;
@@ -22,10 +22,12 @@ class DirectRenderer : public BucketRenderer {
public:
DirectRenderer(const std::string& name, int my_id, int batch_size);
void init_shaders(ShaderLibrary& sl) override;
~DirectRenderer();
void draw_debug_window() override;
void render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) override;
virtual void pre_render() {}
virtual void post_render() {}
~DirectRenderer();
/*!
* Render directly from _VIF_ data.
* You can optionally provide two vif tags that come in front of data.
@@ -58,8 +60,6 @@ class DirectRenderer : public BucketRenderer {
*/
void flush_pending(SharedRenderState* render_state, ScopedProfilerNode& prof);
void draw_debug_window() override;
void hack_disable_blend() {
m_blend_state.a = GsAlpha::BlendMode::SOURCE;
m_blend_state.b = GsAlpha::BlendMode::SOURCE;
@@ -85,6 +85,8 @@ class DirectRenderer : public BucketRenderer {
void handle_uv_packed(const u8* data);
void handle_rgbaq(u64 val);
void handle_xyzf2(u64 val, SharedRenderState* render_state, ScopedProfilerNode& prof);
void lookup_textures_again(SharedRenderState* render_state);
void reinit_hack() { m_prim_gl_state_needs_gl_update = true; }
protected:
virtual void handle_frame(u64 val, SharedRenderState* render_state, ScopedProfilerNode& prof);
@@ -191,6 +193,7 @@ class DirectRenderer : public BucketRenderer {
// vertices will reference these texture states
TextureState m_buffered_tex_state[TEXTURE_STATE_COUNT];
bool m_buffered_tex_state_currently_bound[TEXTURE_STATE_COUNT] = {0};
int m_next_free_tex_state = 0;
// this texture state mirrors the current GS register.
@@ -286,7 +286,7 @@ void OpenGLRenderer::init_bucket_renderers_jak2() {
init_bucket_renderer<DirectRenderer>("debug-no-zbuf1", BucketCategory::OTHER,
BucketId::DEBUG_NO_ZBUF1, 0x8000);
init_bucket_renderer<TextureUploadHandler>("tex-all-map", BucketCategory::TEX,
BucketId::TEX_ALL_MAP, m_texture_animator);
BucketId::TEX_ALL_MAP, m_texture_animator, true);
// 320
init_bucket_renderer<ProgressRenderer>("progress", BucketCategory::OTHER, BucketId::PROGRESS,
0x1000);
@@ -573,7 +573,8 @@ struct TextureAnimPcUpload {
// note that the data can be any format. They upload stuff in the wrong format sometimes, as
// an optimization (ps2 is fastest at psmct32)
u8 format;
u8 pad[3];
u8 force_to_gpu;
u8 pad[2];
};
static_assert(sizeof(TextureAnimPcUpload) == 16);
@@ -1084,6 +1085,9 @@ void TextureAnimator::handle_generic_upload(const DmaTransfer& tf, const u8* ee_
vram.tex_height = upload->height;
memcpy(vram.data.data(), ee_mem + upload->data, vram.data.size());
m_tex_looking_for_clut = nullptr;
if (upload->force_to_gpu) {
m_erased_on_this_frame.insert(upload->dest);
}
break;
case (int)GsTex0::PSM::PSMT8:
vram.kind = VramEntry::Kind::GENERIC_PSMT8;
@@ -1092,6 +1096,9 @@ void TextureAnimator::handle_generic_upload(const DmaTransfer& tf, const u8* ee_
vram.tex_height = upload->height;
memcpy(vram.data.data(), ee_mem + upload->data, vram.data.size());
m_tex_looking_for_clut = &vram;
if (upload->force_to_gpu) {
m_erased_on_this_frame.insert(upload->dest);
}
break;
default:
fmt::print("Unhandled format: {}\n", upload->format);
@@ -11,8 +11,14 @@
TextureUploadHandler::TextureUploadHandler(const std::string& name,
int my_id,
std::shared_ptr<TextureAnimator> texture_animator)
: BucketRenderer(name, my_id), m_texture_animator(texture_animator) {}
std::shared_ptr<TextureAnimator> texture_animator,
bool add_direct)
: BucketRenderer(name, my_id), m_texture_animator(texture_animator) {
if (add_direct) {
m_direct = std::make_unique<DirectRenderer>(name, my_id, 1024 * 6);
m_direct->set_mipmap(false); // try rm
}
}
void TextureUploadHandler::render(DmaFollower& dma,
SharedRenderState* render_state,
@@ -25,15 +31,24 @@ void TextureUploadHandler::render(DmaFollower& dma,
auto dma_tag = dma.current_tag();
auto vif0 = dma.current_tag_vifcode0();
if (vif0.kind == VifCode::Kind::PC_PORT && vif0.immediate == 12) {
dma.read_and_advance();
auto p = scoped_prof("texture-animator");
// note: if both uploads and animator write to the pool, do uploads before the animator.
flush_uploads(uploads, render_state);
uploads.clear();
m_texture_animator->handle_texture_anim_data(dma, (const u8*)render_state->ee_main_memory,
render_state->texture_pool.get(),
render_state->frame_idx);
if (vif0.kind == VifCode::Kind::PC_PORT) {
if (vif0.immediate == 12) {
dma.read_and_advance();
auto p = scoped_prof("texture-animator");
// note: if both uploads and animator write to the pool, do uploads before the animator.
flush_uploads(uploads, render_state);
uploads.clear();
if (m_direct) {
m_direct->flush_pending(render_state, prof);
}
m_texture_animator->handle_texture_anim_data(dma, (const u8*)render_state->ee_main_memory,
render_state->texture_pool.get(),
render_state->frame_idx);
if (m_direct) {
m_direct->lookup_textures_again(render_state);
m_direct->reinit_hack();
}
}
}
// does it look like data to do eye rendering?
if (dma_tag.qwc == (128 / 16)) {
@@ -53,7 +68,6 @@ void TextureUploadHandler::render(DmaFollower& dma,
TextureUpload upload_data;
memcpy(&upload_data, data.data, sizeof(upload_data));
uploads.push_back(upload_data);
continue;
}
@@ -63,10 +77,16 @@ void TextureUploadHandler::render(DmaFollower& dma,
dma.read_and_advance(); // ret
// on next
ASSERT(dma.current_tag_offset() == render_state->next_bucket);
} else if (m_direct) {
m_direct->render_vif(data.vif0(), data.vif1(), data.data, data.size_bytes, render_state,
prof);
}
}
flush_uploads(uploads, render_state);
if (m_direct) {
m_direct->flush_pending(render_state, prof);
}
}
void TextureUploadHandler::flush_uploads(std::vector<TextureUpload>& uploads,
@@ -1,6 +1,7 @@
#pragma once
#include "game/graphics/opengl_renderer/BucketRenderer.h"
#include "game/graphics/opengl_renderer/DirectRenderer.h"
#include "game/graphics/opengl_renderer/TextureAnimator.h"
#include "game/graphics/texture/TexturePool.h"
@@ -13,7 +14,8 @@ class TextureUploadHandler : public BucketRenderer {
public:
TextureUploadHandler(const std::string& name,
int my_id,
std::shared_ptr<TextureAnimator> texture_animator);
std::shared_ptr<TextureAnimator> texture_animator,
bool add_direct = false);
void render(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof) override;
void draw_debug_window() override;
@@ -26,4 +28,5 @@ class TextureUploadHandler : public BucketRenderer {
bool m_fake_uploads = false;
int m_upload_count = 0;
std::shared_ptr<TextureAnimator> m_texture_animator;
std::unique_ptr<DirectRenderer> m_direct;
};
@@ -28,10 +28,12 @@ vec4 sample_tex(vec2 coord, uint unit) {
}
vec4 sample_tex_px(vec2 coordf, uint unit) {
ivec2 coord;
coord.x = int(coordf.x / 16);
coord.y = int(coordf.y / 16);
return texelFetch(tex_T20, coord, 0);
// note: there is still fractional texels and filtering in this mode.
vec2 coord_px = coordf / 16.f;
vec2 tex_size = vec2(textureSize(tex_T20, 0));
// but texture perspective correction is disabled.
// current uses are on quads with the same z so it doesn't really matter.
return textureProj(tex_T20, vec4(coord_px / tex_size, 1, 1));
}
void main() {
+1 -1
View File
@@ -673,7 +673,7 @@
(set! (-> (the-as (pointer float) (+ a0-95 (* a1-94 4))) 0) (-> obj game-score a1-94))
)
(let ((s4-6 (the-as object (+ a0-95 (logand -16 (+ (* v1-153 4) 15))))))
(bigmap-method-13 *bigmap*)
(compress-all *bigmap*)
(let ((v1-161 (-> *bigmap* compressed-next-index)))
(let ((a0-97 (-> (the-as (inline-array game-save-tag) s4-6) 0)))
(set! (-> a0-97 elt-type) (game-save-elt bigmap-data))
@@ -60,6 +60,7 @@
(set! (-> upload-record height) a3-1)
(set! (-> upload-record dest) (-> v1-4 dest 0))
(set! (-> upload-record format) (gs-psm ct32))
(set! (-> upload-record force-to-gpu) 0)
)
(&+! (-> dma-buf base) 16)
@@ -229,6 +230,7 @@
(set! (-> upload-record height) (-> s5-1 h))
(set! (-> upload-record dest) (-> s5-1 dest 0))
(set! (-> upload-record format) (-> s5-1 psm))
(set! (-> upload-record force-to-gpu) 0)
)
(&+! (-> arg0 base) 16)
@@ -204,7 +204,8 @@
(height uint16)
(dest uint32)
(format gs-psm)
(pad uint8 3)
(force-to-gpu uint8)
(pad uint8 2)
)
:size-assert 16
)
+6 -1
View File
@@ -934,7 +934,11 @@ additionally, some texture pages have a chunk system that allows more specific c
(defun upload-vram-data ((buf dma-buffer) (dest int) (data pointer) (height int) (width int))
"Generate DMA data to upload texture. This simply sets up a texture upload to happen in the future.
The texture data itself is referenced, not copied into the dma-buffer."
The texture data itself is referenced, not copied into the dma-buffer."
(#when PC_PORT
;; disabled.
(return #f)
)
(while (> height 0)
(let ((height-this-time (min 2048 height)))
(dma-buffer-add-gs-set buf
@@ -1913,6 +1917,7 @@ additionally, some texture pages have a chunk system that allows more specific c
(#when PC_PORT
;; as far as I know this is only used for fonts which have 1 mip level.
(__pc-texture-relocate (/ dest-loc 64) (-> tex dest 0) dest-fmt)
(return dma-buff)
)
(dotimes (v1-0 (the-as int (-> tex num-mips)))
(let ((t1-1 (ash (-> tex w) (- v1-0)))
+17 -17
View File
@@ -137,25 +137,25 @@
:flag-assert #x1c000001b4
(:methods
(new (symbol type) _type_ 0)
(initialize (_type_) none 9)
(initialize (_type_) none 9) ;; some sort of init?
(update (_type_) none 10)
(bigmap-method-11 (_type_ int int int int) int 11)
(bigmap-method-12 (_type_) int 12)
(bigmap-method-13 (_type_) int 13)
(bigmap-method-14 (_type_) none 14)
(bigmap-method-15 (_type_) int 15)
(draw (_type_ int int int int) int 11)
(handle-cpad-inputs (_type_) int 12)
(compress-all (_type_) int 13)
(enable-drawing (_type_) none 14)
(disable-drawing (_type_) int 15)
(dump-to-file (_type_) file-stream 16)
(bigmap-method-17 (_type_ vector) int 17)
(bigmap-method-18 (_type_) int 18)
(bigmap-method-19 (_type_) int 19)
(bigmap-method-20 (_type_) int 20)
(bigmap-method-21 (_type_ int int) int 21)
(bigmap-method-22 (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(bigmap-method-23 (_type_) none 23)
(bigmap-method-24 (_type_ dma-buffer) none 24)
(bigmap-method-25 (_type_ dma-buffer) none 25)
(bigmap-method-26 (_type_ dma-buffer int int int int) none 26)
(bigmap-method-27 (_type_ dma-buffer connection-minimap) int 27)
(set-pos! (_type_ vector) int 17)
(decompress-current-masks! (_type_) int 18)
(compress-current-masks! (_type_) int 19)
(set-enable-from-position! (_type_) int 20)
(maybe-fill-for-position (_type_ int int) int 21)
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(mask-image-from-bit-mask (_type_) none 23)
(draw-non-city-map (_type_ dma-buffer) none 24)
(draw-city-map (_type_ dma-buffer) none 25)
(sprite-dma (_type_ dma-buffer int int int int) none 26)
(draw-from-minimap (_type_ dma-buffer connection-minimap) int 27)
)
)
+191 -72
View File
@@ -7,7 +7,20 @@
;; DECOMP BEGINS
(defmethod bigmap-method-17 bigmap ((obj bigmap) (arg0 vector))
;; The "bigmap" has a number of layers, each corresponding to a map/location in-game.
;; Each layer has a "mask", which stores a 1-bit value for each cell in a grid. This layer is updated as the game
;; is played to indicate if the player has "seen" this area, and if it should be shown on the map.
;; If the player is near an area, it will be marked as visible.
;; There's also a layer mask, which stores a 4-bit value per cell. This is used to segment the map into different regions.
;; The filling operation will not allow you to "see" areas that don't match the value of your current position.
;; This can be used to prevent the player from seeing stuff behind a wall by giving the space on either side
;; of the wall a different layer-mask value.
;; The bit-mask data can be compressed, for including it in saves.
(defmethod set-pos! bigmap ((obj bigmap) (arg0 vector))
"Set (-> obj pos) to the integer cell index for the given floating-point position."
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
@@ -15,42 +28,67 @@
(init-vf0-vector)
(.lvf vf1 (&-> arg0 quad))
(.lvf vf2 (&-> obj offset quad))
;; move z to y. We want the 2D position in xy.
(.add.z.vf vf1 vf0 vf1 :mask #b10)
;; apply offset
(.sub.vf vf1 vf1 vf2)
;; apply scaling.
(.mul.w.vf vf1 vf1 vf2)
;; convert to integer
(.ftoi.vf vf1 vf1)
(.svf (&-> obj pos quad) vf1)
0
)
)
(defmethod bigmap-method-18 bigmap ((obj bigmap))
(let ((s5-0 (-> obj compressed-masks (-> obj mask-index))))
(defmethod decompress-current-masks! bigmap ((obj bigmap))
"Decompress the layer set by (-> obj mask-index).
The decompressed result will be stored in (-> obj bit-mask data).
If it was never compressed, the data will be set to 0."
(let ((compressed-mask-data (-> obj compressed-masks (-> obj mask-index))))
;; mark compressed data as invalid as we will remove the compressed data after decompression.
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) #f))
;; check if we have compressed data
(cond
(s5-0
(let* ((a0-2 (unpack-comp-rle (the-as (pointer int8) (-> obj bit-mask data)) s5-0))
(v1-7 (&- a0-2 (the-as uint s5-0)))
(compressed-mask-data
;; decompress to (-> obj bit-mask data)
(let* ((decompressed-data-end (unpack-comp-rle (the-as (pointer int8) (-> obj bit-mask data)) compressed-mask-data))
(decompressed-size (&- decompressed-data-end (the-as uint compressed-mask-data)))
)
(let ((a1-3 (+ (- (the-as int s5-0)) (-> obj compressed-data) (-> obj compressed-next-index))))
(dotimes (a2-2 a1-3)
(set! (-> s5-0 a2-2) (the-as int (-> (the-as (pointer uint8) (&+ a0-2 a2-2)))))
;; we no longer need to keep this compressed data.
;; there is a single buffer (-> obj compressed-data) that stores all compressed layers.
;; when removing a layer, we need to compact the heap by shifting things in memory after this one backward.
;; determine how many bytes are in use after the compressed data we just used
(let ((bytes-to-shift-back
(+ (- (the-as int compressed-mask-data)) (-> obj compressed-data) (-> obj compressed-next-index))
)
)
;; copy backward.
(dotimes (byte-idx bytes-to-shift-back)
(set! (-> compressed-mask-data byte-idx)
(the-as int (-> (the-as (pointer uint8) (&+ decompressed-data-end byte-idx))))
)
)
)
(dotimes (a0-5 20)
(let ((a1-6 (-> obj compressed-masks a0-5)))
(if (and a1-6 (>= (the-as int a1-6) (the-as int s5-0)))
(set! (-> obj compressed-masks a0-5) (the-as (pointer int8) (&- a1-6 (the-as uint v1-7))))
;; update references to the compressed arrays we just moved.
(dotimes (layer-idx 20)
(let ((layer-data (-> obj compressed-masks layer-idx)))
;; only update if past this compressed layer and was moved.
(if (and layer-data (>= (the-as int layer-data) (the-as int compressed-mask-data)))
(set! (-> obj compressed-masks layer-idx) (the (pointer int8) (&- layer-data (the-as uint decompressed-size))))
)
)
)
(set! (-> obj compressed-next-index) (- (-> obj compressed-next-index) (the-as uint v1-7)))
;; update end-of-heap pointer to account for the memory we just freed.
(set! (-> obj compressed-next-index) (- (-> obj compressed-next-index) (the-as uint decompressed-size)))
)
)
(else
(let ((v1-10 (-> obj bit-mask data)))
(dotimes (a0-9 416)
(set! (-> (the-as (pointer uint128) (&+ v1-10 (* a0-9 16)))) (the-as uint128 0))
;; there was no compressed data. Initialize masks to 0.
(let ((data (-> obj bit-mask data)))
(dotimes (qw-idx 416)
(set! (-> (the-as (pointer int128) (&+ data (* qw-idx 16)))) (the int128 0))
)
)
)
@@ -59,20 +97,28 @@
0
)
(defmethod bigmap-method-19 bigmap ((obj bigmap))
(let* ((s5-0 (+ (-> obj compressed-next-index) 0 (-> obj compressed-data)))
(v1-4
(defmethod compress-current-masks! bigmap ((obj bigmap))
"Take the current (-> obj bit-mask data), and store it in the compressed layer buffer."
;; store at the end of the buffer
(let* ((compressed-data-dest (+ (-> obj compressed-next-index) 0 (-> obj compressed-data)))
;; compress!
(compressed-data-size
(pack-comp-rle
(the-as (pointer uint8) s5-0)
(the-as (pointer uint8) compressed-data-dest)
(-> obj bit-mask data)
6656
(the-as int (- #x8000 (the-as int (-> obj compressed-next-index))))
)
)
)
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) s5-0))
(set! (-> obj compressed-next-index) (the-as uint (+ (-> obj compressed-next-index) (the-as uint v1-4))))
;; store pointer to the compressed data
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) compressed-data-dest))
;; update end of the heap
(set! (-> obj compressed-next-index)
(the-as uint (+ (-> obj compressed-next-index) (the-as uint compressed-data-size)))
)
)
;; track max buffer use.
(set! (-> obj max-next-index)
(the-as uint (max (the-as int (-> obj max-next-index)) (the-as int (-> obj compressed-next-index))))
)
@@ -135,8 +181,14 @@
)
)
(defmethod bigmap-method-20 bigmap ((obj bigmap))
(defmethod set-enable-from-position! bigmap ((obj bigmap))
"Read the value of the layer-mask at the current position.
Future calls to maybe-fill-for-position will only succeed
if they correspond to a cell with the same layer-mask value
as this position."
;; each byte stores 2 mask values.
(let ((v1-4 (-> obj layer-mask data (+ (* (-> obj pos y) 128) (/ (-> obj pos x) 2)))))
;; pick the low/high part of the byte.
(if (not (logtest? (-> obj pos x) 1))
(set! (-> obj layer-mask-enable) (shr v1-4 4))
(set! (-> obj layer-mask-enable) (logand v1-4 15))
@@ -145,7 +197,9 @@
0
)
(defmethod bigmap-method-21 bigmap ((obj bigmap) (arg0 int) (arg1 int))
(defmethod maybe-fill-for-position bigmap ((obj bigmap) (arg0 int) (arg1 int))
"Check the layer-mask for this position. If it matches the value read from
set-enable-from-position, then set the bit in the bit-mask."
(local-vars (v1-3 uint))
(let* ((v1-1 (+ (* arg1 128) (/ arg0 2)))
(a3-3 (-> obj layer-mask data v1-1))
@@ -186,7 +240,8 @@
)
)
(defmethod bigmap-method-23 bigmap ((obj bigmap))
(defmethod mask-image-from-bit-mask bigmap ((obj bigmap))
"Modify the image-data in place to mask out parts of the map that have not been seen."
(let* ((v1-0 (the-as object (-> obj bit-mask)))
(a1-0 *image-mask-table*)
(a0-2 (the-as object (-> obj bigmap-image art-group)))
@@ -219,7 +274,35 @@
(none)
)
(defmethod bigmap-method-22 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
(defun pc-upload-map-texture ((dma-buf dma-buffer) (image-data pointer) (clut-data pointer) (width int) (height int) (tbp int) (cbp int))
"Added function in the PC port to create a map texture. The format should be mt8 for the image and ct32 for the clut (16 x 16)"
(pc-texture-anim-flag start-anim-array dma-buf)
(pc-texture-anim-flag upload-clut-16-16 dma-buf :qwc 1)
(let ((upload-record (the texture-anim-pc-upload (-> dma-buf base))))
(set! (-> upload-record data) clut-data)
(set! (-> upload-record width) 16)
(set! (-> upload-record height) 16)
(set! (-> upload-record dest) cbp)
(set! (-> upload-record format) (gs-psm ct32))
(set! (-> upload-record force-to-gpu) 0)
)
(&+! (-> dma-buf base) 16)
(pc-texture-anim-flag upload-generic-vram dma-buf :qwc 1)
(let ((upload-record (the texture-anim-pc-upload (-> dma-buf base))))
(set! (-> upload-record data) image-data)
(set! (-> upload-record width) width)
(set! (-> upload-record height) height)
(set! (-> upload-record dest) tbp)
(set! (-> upload-record format) (gs-psm mt8))
(set! (-> upload-record force-to-gpu) 1)
)
(&+! (-> dma-buf base) 16)
(pc-texture-anim-flag finish-anim-array dma-buf)
)
(defmethod texture-upload-dma bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
"Add a texture upload to the DMA buffer."
(local-vars (sv-16 int))
(set! sv-16 arg2)
(dma-buffer-add-gs-set arg0
@@ -233,8 +316,8 @@
(none)
)
;; WARN: Return type mismatch pointer vs none.
(defmethod bigmap-method-26 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
(defmethod sprite-dma bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
"Generate DMA for drawing a single sprite."
(let ((v1-0 (-> arg0 base)))
(set! (-> (the-as (pointer uint128) v1-0) 0) (-> obj sprite-tmpl dma-vif quad))
(set! (-> (the-as (pointer uint128) v1-0) 1) (-> obj sprite-tmpl quad 1))
@@ -248,70 +331,99 @@
(none)
)
(defmethod bigmap-method-24 bigmap ((obj bigmap) (arg0 dma-buffer))
(defmethod draw-non-city-map bigmap ((obj bigmap) (arg0 dma-buffer))
"Generate DMA to draw a non-city map using the loaded bigmap image.
This appears to have 3 layers."
(let ((s4-0 (the-as (pointer uint32) (-> obj bigmap-image art-group))))
(let ((v1-1 (-> s4-0 0))
(s3-0 (-> s4-0 1))
)
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-1 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ s3-0 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
;; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-1 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
;; (dma-buffer-add-gs-set arg0 (texflush 1))
;; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ s3-0 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
;; Added
(pc-upload-map-texture arg0 (&+ s4-0 s3-0 16) (&+ s4-0 v1-1 16) 512 208 8 0)
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :cld #x1))
(tex1-1 (new 'static 'gs-tex1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-16 (+ #x1a000 (-> s4-0 1))))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-16 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
;;(texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-16 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
(pc-upload-map-texture arg0 (&+ s4-0 v1-16 16) (&+ s4-0 (-> s4-0 0) 16) 512 208 8 0)
)
(dma-buffer-add-gs-set arg0 (texflush 0))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(let ((v1-25 (+ (-> s4-0 0) 1024))
(s3-1 (+ #x34000 (-> s4-0 1)))
)
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-25 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ s3-1 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
;; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-25 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
;; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ s3-1 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
(pc-upload-map-texture arg0 (&+ s4-0 s3-1 16) (&+ s4-0 v1-25 16) 512 208 8 0)
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :tcc #x1 :cld #x1))
(tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-37 (+ #x4e000 (-> s4-0 1))))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-37 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
;; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-37 16) (the-as uint s4-0))) 8 512 208 (gs-psm mt8))
(pc-upload-map-texture arg0 (&+ s4-0 v1-37 16) (&+ s4-0 (+ (-> s4-0 0) 1024) 16) 512 208 8 0)
)
)
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(none)
)
(defmethod bigmap-method-25 bigmap ((obj bigmap) (arg0 dma-buffer))
(defmethod draw-city-map bigmap ((obj bigmap) (arg0 dma-buffer))
"Generate DMA to draw the city map. This has only 2 layers, but has scrolling."
(let ((s4-0 (the-as (pointer uint32) (-> obj bigmap-image art-group))))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ (-> s4-0 0) 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
(dma-buffer-add-gs-set arg0 (texflush 0))
; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ (-> s4-0 0) 16) (the-as uint s4-0))) 0 16 16 (gs-psm ct32))
; (dma-buffer-add-gs-set arg0 (texflush 0))
(let ((v1-10 (+ (* (the int (-> obj scroll y)) 512) (-> s4-0 1))))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-10 16) (the-as int s4-0))) 8 512 208 (gs-psm mt8))
; (texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-10 16) (the-as int s4-0))) 8 512 208 (gs-psm mt8))
(pc-upload-map-texture
arg0 ;; dma
(&+ s4-0 v1-10 16) ;; image data
(&+ s4-0 (-> s4-0 0) 16) ;; clut data
512 ;; width
208 ;; height
8 ;; dest
0 ;; clut dest
)
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :cld #x1))
(tex1-1 (new 'static 'gs-tex1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-21 (+ (* (+ (the int (-> obj scroll y)) 208) 512) (-> s4-0 1))))
(bigmap-method-22 obj arg0 (the-as (pointer uint32) (+ (+ v1-21 16) (the-as int s4-0))) 8 512 208 (gs-psm mt8))
;(texture-upload-dma obj arg0 (the-as (pointer uint32) (+ (+ v1-21 16) (the-as int s4-0))) 8 512 208 (gs-psm mt8))
(pc-upload-map-texture
arg0 ;; dma
(&+ s4-0 v1-21 16) ;; image data
(&+ s4-0 (-> s4-0 0) 16) ;; clut data
512 ;; width
208 ;; height
8 ;; dest
0 ;; clut dest
)
)
)
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
;(dma-buffer-add-gs-set arg0 (texflush 1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(none)
)
(defmethod bigmap-method-27 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
(defmethod draw-from-minimap bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
"Read data from a minimap connection and draw it on the bigmap."
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
@@ -468,7 +580,7 @@
(not (load-in-progress? *level*))
)
(if (!= (-> obj bigmap-index) 20)
(bigmap-method-23 obj)
(mask-image-from-bit-mask obj)
)
(let ((s5-0 (-> *level* loading-level))
(s4-0 (-> *texture-pool* allocate-func))
@@ -496,10 +608,10 @@
(set! (-> obj offset quad) (-> *bigmap-info-array* data (-> obj mask-index) quad))
(when (!= (-> obj bigmap-index) (-> obj mask-index))
(if (!= (-> obj mask-index) 20)
(bigmap-method-19 obj)
(compress-current-masks! obj)
)
(set! (-> obj mask-index) (-> obj bigmap-index))
(bigmap-method-18 obj)
(decompress-current-masks! obj)
)
(when (!= (-> obj bigmap-index) (-> obj layer-index))
(set! (-> obj layer-index) (-> obj bigmap-index))
@@ -508,8 +620,8 @@
(the-as (pointer int8) (-> obj compressed-layers data (-> obj layer-index)))
)
)
(bigmap-method-17 obj (target-pos 0))
(bigmap-method-20 obj)
(set-pos! obj (target-pos 0))
(set-enable-from-position! obj)
(cond
((-> obj recording-flag)
(when (-> obj fill-flag)
@@ -517,7 +629,7 @@
(a2-5 (-> obj pos y))
)
(if (and (>= a1-9 0) (< a1-9 256) (>= a2-5 0) (< a2-5 208))
(bigmap-method-21 obj a1-9 a2-5)
(maybe-fill-for-position obj a1-9 a2-5)
)
)
)
@@ -538,7 +650,7 @@
(a2-6 (+ (-> obj pos y) s5-2))
)
(if (and (>= a1-10 0) (< a1-10 256) (>= a2-6 0) (< a2-6 208))
(bigmap-method-21 obj a1-10 a2-6)
(maybe-fill-for-position obj a1-10 a2-6)
)
)
(+! s3-1 1)
@@ -558,8 +670,7 @@
(none)
)
;; ERROR: Failed store: (s.w! (+ v1-35 8) 0) at op 125
(defmethod bigmap-method-11 bigmap ((obj bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
(defmethod draw bigmap ((obj bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
(local-vars (sv-96 pointer) (sv-100 texture) (sv-104 matrix) (sv-112 int))
(with-pp
(when (and (= (file-status (-> obj bigmap-image) "world-map" (the-as int (-> obj load-index))) 'active)
@@ -589,8 +700,8 @@
(clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
)
(if (= (-> obj bigmap-index) 20)
(bigmap-method-25 obj s4-1)
(bigmap-method-24 obj s4-1)
(draw-city-map obj s4-1)
(draw-non-city-map obj s4-1)
)
)
(with-dma-buffer-add-bucket ((s4-2 (-> *display* frames (-> *display* on-screen) global-buf))
@@ -616,11 +727,11 @@
(when (logtest? (-> a2-3 class flags) (minimap-flag bigmap))
(cond
((= (-> obj bigmap-index) 20)
(bigmap-method-27 obj s4-2 a2-3)
(draw-from-minimap obj s4-2 a2-3)
)
(else
(if (not (logtest? (-> a2-3 class flags) (minimap-flag city-only)))
(bigmap-method-27 obj s4-2 a2-3)
(draw-from-minimap obj s4-2 a2-3)
)
)
)
@@ -641,7 +752,7 @@
(set! sv-104 (new 'stack-no-clear 'matrix))
(set! sv-112 (the int (* 56.0 f30-0)))
(when sv-100
(bigmap-method-17 obj (target-pos 0))
(set-pos! obj (target-pos 0))
(if (-> *blit-displays-work* horizontal-flip-flag)
(set! f30-0 (- f30-0))
)
@@ -721,7 +832,7 @@
)
)
(defmethod bigmap-method-12 bigmap ((obj bigmap))
(defmethod handle-cpad-inputs bigmap ((obj bigmap))
(cond
((= (-> obj bigmap-index) 20)
(let* ((v1-2 (-> *cpad-list* cpads 0))
@@ -738,20 +849,19 @@
0
)
(defmethod bigmap-method-13 bigmap ((obj bigmap))
(defmethod compress-all bigmap ((obj bigmap))
(when (!= (-> obj mask-index) 20)
(bigmap-method-19 obj)
(compress-current-masks! obj)
(set! (-> obj mask-index) (the-as uint 20))
)
0
)
;; WARN: Return type mismatch symbol vs none.
(defmethod bigmap-method-14 bigmap ((obj bigmap))
(defmethod enable-drawing bigmap ((obj bigmap))
(set! (-> obj bigmap-index) (the-as uint (-> (level-get-target-inside *level*) info bigmap-id)))
(cond
((= (-> obj bigmap-index) 20)
(bigmap-method-17 obj (target-pos 0))
(set-pos! obj (target-pos 0))
(set! (-> obj scroll y) (the float (max 0 (+ (* (-> obj pos y) 2) -208))))
(set-vector! (-> obj draw-offset) -2621440.0 -4456448.0 16384.0 0.000030517578)
(cond
@@ -788,7 +898,7 @@
(none)
)
(defmethod bigmap-method-15 bigmap ((obj bigmap))
(defmethod disable-drawing bigmap ((obj bigmap))
(set-pending-file
(-> obj bigmap-image)
(the-as string #f)
@@ -814,8 +924,10 @@
0
)
;; definition for symbol *map-save-ptr*, type (pointer uint64)
(define *map-save-ptr* (the-as (pointer uint64) #f))
;; definition for method 16 of type bigmap
(defmethod dump-to-file bigmap ((obj bigmap))
(if (not *map-save-ptr*)
(set! *map-save-ptr* (the-as (pointer uint64) (malloc 'debug #xd0000)))
@@ -860,8 +972,15 @@
)
)
;; failed to figure out what this is:
(kmemopen global "bigmap")
(define *bigmap* (new 'global 'bigmap))
;; definition for symbol *bigmap*, type bigmap
(define-perm *bigmap* bigmap (new 'global 'bigmap))
;; failed to figure out what this is:
(kmemclose)
+6 -6
View File
@@ -398,7 +398,7 @@
(process-spawn hud-ring-cell 12 (* -2.0 f30-0) 8 :to self)
(process-spawn hud-ring-cell 11 (* -1.0 f30-0) 9 :to self)
)
(bigmap-method-14 *bigmap*)
(enable-drawing *bigmap*)
(go-virtual come-in)
)
@@ -459,7 +459,7 @@
(defmethod deactivate progress ((obj progress))
(remove-setting-by-arg0 *setting-control* 'extra-bank)
(bigmap-method-15 *bigmap*)
(disable-drawing *bigmap*)
(set! (-> *blit-displays-work* menu-mode) #f)
(set! *progress-process* (the-as (pointer progress) #f))
(enable-level-text-file-loading)
@@ -1362,7 +1362,7 @@
(when (and (< 0.8 (-> self anim-frame)) (or (= (-> self current) 'bigmap) (= (-> self next) 'bigmap)))
(cond
((>= (-> self pos-transition) 0.38)
(bigmap-method-11 *bigmap* 1792 1840 2304 2256)
(draw *bigmap* 1792 1840 2304 2256)
)
(else
(let ((s4-2 (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 21)))
@@ -1373,7 +1373,7 @@
(let ((s5-1 (new 'stack-no-clear 'vector4w)))
(set! (-> s5-1 quad) (the-as uint128 0))
(if (and (transform-point-qword! gp-1 s4-2) (transform-point-qword! s5-1 s3-1))
(bigmap-method-11 *bigmap* (/ (-> s5-1 x) 16) (/ (-> s5-1 y) 16) (/ (-> gp-1 x) 16) (/ (-> gp-1 y) 16))
(draw *bigmap* (/ (-> s5-1 x) 16) (/ (-> s5-1 y) 16) (/ (-> gp-1 x) 16) (/ (-> gp-1 y) 16))
)
)
)
@@ -1706,7 +1706,7 @@
(defstate gone (progress)
:virtual #t
:code (behavior ()
(bigmap-method-15 *bigmap*)
(disable-drawing *bigmap*)
(set! (-> *blit-displays-work* menu-mode) #f)
(while (or (-> *blit-displays-work* screen-copied) (nonzero? (-> *blit-displays-work* count-down)))
(suspend)
@@ -2996,7 +2996,7 @@
(defmethod respond-progress menu-bigmap-option ((obj menu-bigmap-option) (arg0 progress) (arg1 symbol))
"Handle progress menu navigation logic."
(bigmap-method-12 *bigmap*)
(handle-cpad-inputs *bigmap*)
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons confirm))
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons confirm))
0
+1 -1
View File
@@ -877,7 +877,7 @@
(set! (-> (the-as (pointer float) (+ a0-95 (* a1-94 4))) 0) (-> obj game-score a1-94))
)
(let ((s4-6 (the-as object (+ a0-95 (logand -16 (+ (* v1-153 4) 15))))))
(bigmap-method-13 *bigmap*)
(compress-all *bigmap*)
(let ((v1-161 (-> *bigmap* compressed-next-index)))
(let ((a0-97 (-> (the-as (inline-array game-save-tag) s4-6) 0)))
(set! (-> a0-97 elt-type) (game-save-elt bigmap-data))
+16 -16
View File
@@ -231,23 +231,23 @@
(new (symbol type) _type_ 0)
(initialize (_type_) none 9)
(update (_type_) none 10)
(bigmap-method-11 (_type_ int int int int) int 11)
(bigmap-method-12 (_type_) int 12)
(bigmap-method-13 (_type_) int 13)
(bigmap-method-14 (_type_) none 14)
(bigmap-method-15 (_type_) int 15)
(draw (_type_ int int int int) int 11)
(handle-cpad-inputs (_type_) int 12)
(compress-all (_type_) int 13)
(enable-drawing (_type_) none 14)
(disable-drawing (_type_) int 15)
(dump-to-file (_type_) file-stream 16)
(bigmap-method-17 (_type_ vector) int 17)
(bigmap-method-18 (_type_) int 18)
(bigmap-method-19 (_type_) int 19)
(bigmap-method-20 (_type_) int 20)
(bigmap-method-21 (_type_ int int) int 21)
(bigmap-method-22 (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(bigmap-method-23 (_type_) none 23)
(bigmap-method-24 (_type_ dma-buffer) none 24)
(bigmap-method-25 (_type_ dma-buffer) none 25)
(bigmap-method-26 (_type_ dma-buffer int int int int) none 26)
(bigmap-method-27 (_type_ dma-buffer connection-minimap) int 27)
(set-pos! (_type_ vector) int 17)
(decompress-current-masks! (_type_) int 18)
(compress-current-masks! (_type_) int 19)
(set-enable-from-position! (_type_) int 20)
(maybe-fill-for-position (_type_ int int) int 21)
(texture-upload-dma (_type_ dma-buffer (pointer uint32) int int int gs-psm) none 22)
(mask-image-from-bit-mask (_type_) none 23)
(draw-non-city-map (_type_ dma-buffer) none 24)
(draw-city-map (_type_ dma-buffer) none 25)
(sprite-dma (_type_ dma-buffer int int int int) none 26)
(draw-from-minimap (_type_ dma-buffer connection-minimap) int 27)
)
)
+72 -65
View File
@@ -2,7 +2,7 @@
(in-package goal)
;; definition for method 17 of type bigmap
(defmethod bigmap-method-17 bigmap ((obj bigmap) (arg0 vector))
(defmethod set-pos! bigmap ((obj bigmap) (arg0 vector))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
@@ -21,33 +21,38 @@
;; definition for method 18 of type bigmap
;; INFO: Used lq/sq
(defmethod bigmap-method-18 bigmap ((obj bigmap))
(let ((s5-0 (-> obj compressed-masks (-> obj mask-index))))
(defmethod decompress-current-masks! bigmap ((obj bigmap))
(let ((compressed-mask-data (-> obj compressed-masks (-> obj mask-index))))
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) #f))
(cond
(s5-0
(let* ((a0-2 (unpack-comp-rle (the-as (pointer int8) (-> obj bit-mask data)) s5-0))
(v1-7 (&- a0-2 (the-as uint s5-0)))
(compressed-mask-data
(let* ((decompressed-data-end (unpack-comp-rle (the-as (pointer int8) (-> obj bit-mask data)) compressed-mask-data))
(decompressed-size (&- decompressed-data-end (the-as uint compressed-mask-data)))
)
(let ((a1-3 (+ (- (the-as int s5-0)) (-> obj compressed-data) (-> obj compressed-next-index))))
(dotimes (a2-2 a1-3)
(set! (-> s5-0 a2-2) (the-as int (-> (the-as (pointer uint8) (&+ a0-2 a2-2)))))
(let ((bytes-to-shift-back
(+ (- (the-as int compressed-mask-data)) (-> obj compressed-data) (-> obj compressed-next-index))
)
)
(dotimes (byte-idx bytes-to-shift-back)
(set! (-> compressed-mask-data byte-idx)
(the-as int (-> (the-as (pointer uint8) (&+ decompressed-data-end byte-idx))))
)
)
)
(dotimes (a0-5 20)
(let ((a1-6 (-> obj compressed-masks a0-5)))
(if (and a1-6 (>= (the-as int a1-6) (the-as int s5-0)))
(set! (-> obj compressed-masks a0-5) (&- a1-6 (the-as uint v1-7)))
(dotimes (layer-idx 20)
(let ((layer-data (-> obj compressed-masks layer-idx)))
(if (and layer-data (>= (the-as int layer-data) (the-as int compressed-mask-data)))
(set! (-> obj compressed-masks layer-idx) (&- layer-data (the-as uint decompressed-size)))
)
)
)
(set! (-> obj compressed-next-index) (- (-> obj compressed-next-index) (the-as uint v1-7)))
(set! (-> obj compressed-next-index) (- (-> obj compressed-next-index) (the-as uint decompressed-size)))
)
)
(else
(let ((v1-10 (-> obj bit-mask data)))
(dotimes (a0-9 416)
(set! (-> (the-as (pointer int128) (&+ v1-10 (* a0-9 16)))) 0)
(let ((data (-> obj bit-mask data)))
(dotimes (qw-idx 416)
(set! (-> (the-as (pointer int128) (&+ data (* qw-idx 16)))) 0)
)
)
)
@@ -57,19 +62,21 @@
)
;; definition for method 19 of type bigmap
(defmethod bigmap-method-19 bigmap ((obj bigmap))
(let* ((s5-0 (+ (-> obj compressed-next-index) 0 (-> obj compressed-data)))
(v1-4
(defmethod compress-current-masks! bigmap ((obj bigmap))
(let* ((compressed-data-dest (+ (-> obj compressed-next-index) 0 (-> obj compressed-data)))
(compressed-data-size
(pack-comp-rle
(the-as (pointer uint8) s5-0)
(the-as (pointer uint8) compressed-data-dest)
(-> obj bit-mask data)
6656
(the-as int (- #x8000 (the-as int (-> obj compressed-next-index))))
)
)
)
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) s5-0))
(set! (-> obj compressed-next-index) (the-as uint (+ (-> obj compressed-next-index) (the-as uint v1-4))))
(set! (-> obj compressed-masks (-> obj mask-index)) (the-as (pointer int8) compressed-data-dest))
(set! (-> obj compressed-next-index)
(the-as uint (+ (-> obj compressed-next-index) (the-as uint compressed-data-size)))
)
)
(set! (-> obj max-next-index)
(the-as uint (max (the-as int (-> obj max-next-index)) (the-as int (-> obj compressed-next-index))))
@@ -136,7 +143,7 @@
)
;; definition for method 20 of type bigmap
(defmethod bigmap-method-20 bigmap ((obj bigmap))
(defmethod set-enable-from-position! bigmap ((obj bigmap))
(let ((v1-4 (-> obj layer-mask data (+ (* (-> obj pos y) 128) (/ (-> obj pos x) 2)))))
(if (not (logtest? (-> obj pos x) 1))
(set! (-> obj layer-mask-enable) (shr v1-4 4))
@@ -147,7 +154,7 @@
)
;; definition for method 21 of type bigmap
(defmethod bigmap-method-21 bigmap ((obj bigmap) (arg0 int) (arg1 int))
(defmethod maybe-fill-for-position bigmap ((obj bigmap) (arg0 int) (arg1 int))
(local-vars (v1-3 uint))
(let* ((v1-1 (+ (* arg1 128) (/ arg0 2)))
(a3-3 (-> obj layer-mask data v1-1))
@@ -191,7 +198,7 @@
;; definition for method 23 of type bigmap
;; WARN: Return type mismatch int vs none.
(defmethod bigmap-method-23 bigmap ((obj bigmap))
(defmethod mask-image-from-bit-mask bigmap ((obj bigmap))
(let* ((v1-0 (the-as object (-> obj bit-mask)))
(a1-0 *image-mask-table*)
(a0-2 (the-as object (-> obj bigmap-image art-group)))
@@ -226,7 +233,7 @@
;; definition for method 22 of type bigmap
;; WARN: Return type mismatch int vs none.
(defmethod bigmap-method-22 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
(defmethod texture-upload-dma bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 (pointer uint32)) (arg2 int) (arg3 int) (arg4 int) (arg5 gs-psm))
(local-vars (sv-16 int))
(set! sv-16 arg2)
(dma-buffer-add-gs-set arg0
@@ -243,7 +250,7 @@
;; definition for method 26 of type bigmap
;; INFO: Used lq/sq
;; WARN: Return type mismatch pointer vs none.
(defmethod bigmap-method-26 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
(defmethod sprite-dma bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 int) (arg2 int) (arg3 int) (arg4 int))
(let ((v1-0 (-> arg0 base)))
(set! (-> (the-as (pointer uint128) v1-0) 0) (-> obj sprite-tmpl dma-vif quad))
(set! (-> (the-as (pointer uint128) v1-0) 1) (-> obj sprite-tmpl quad 1))
@@ -258,73 +265,73 @@
)
;; definition for method 24 of type bigmap
(defmethod bigmap-method-24 bigmap ((obj bigmap) (arg0 dma-buffer))
(defmethod draw-non-city-map bigmap ((obj bigmap) (arg0 dma-buffer))
(let ((s4-0 (the-as (pointer uint32) (-> obj bigmap-image art-group))))
(let ((v1-1 (-> s4-0 0))
(s3-0 (-> s4-0 1))
)
(bigmap-method-22 obj arg0 (+ (+ v1-1 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(texture-upload-dma obj arg0 (+ (+ v1-1 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-22 obj arg0 (+ (+ s3-0 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ s3-0 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :cld #x1))
(tex1-1 (new 'static 'gs-tex1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-16 (+ #x1a000 (-> s4-0 1))))
(bigmap-method-22 obj arg0 (+ (+ v1-16 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ v1-16 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
)
(dma-buffer-add-gs-set arg0 (texflush 0))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(let ((v1-25 (+ (-> s4-0 0) 1024))
(s3-1 (+ #x34000 (-> s4-0 1)))
)
(bigmap-method-22 obj arg0 (+ (+ v1-25 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(bigmap-method-22 obj arg0 (+ (+ s3-1 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ v1-25 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(texture-upload-dma obj arg0 (+ (+ s3-1 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :tcc #x1 :cld #x1))
(tex1-1 (new 'static 'gs-tex1 :mmag #x1 :mmin #x1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-37 (+ #x4e000 (-> s4-0 1))))
(bigmap-method-22 obj arg0 (+ (+ v1-37 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ v1-37 16) (the-as uint s4-0)) 8 512 208 (gs-psm mt8))
)
)
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(none)
)
;; definition for method 25 of type bigmap
(defmethod bigmap-method-25 bigmap ((obj bigmap) (arg0 dma-buffer))
(defmethod draw-city-map bigmap ((obj bigmap) (arg0 dma-buffer))
(let ((s4-0 (the-as (pointer uint32) (-> obj bigmap-image art-group))))
(bigmap-method-22 obj arg0 (+ (+ (-> s4-0 0) 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(texture-upload-dma obj arg0 (+ (+ (-> s4-0 0) 16) (the-as uint s4-0)) 0 16 16 (gs-psm ct32))
(dma-buffer-add-gs-set arg0 (texflush 0))
(let ((v1-10 (+ (* (the int (-> obj scroll y)) 512) (-> s4-0 1))))
(bigmap-method-22 obj arg0 (+ (+ v1-10 16) (the-as int s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ v1-10 16) (the-as int s4-0)) 8 512 208 (gs-psm mt8))
)
(dma-buffer-add-gs-set arg0
(tex0-1 (new 'static 'gs-tex0 :tbp0 #x8 :tbw #x8 :psm #x13 :tw #x9 :th #x9 :cld #x1))
(tex1-1 (new 'static 'gs-tex1))
(texflush 1)
)
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(sprite-dma obj arg0 (-> obj x0) (-> obj y0) (-> obj x1) (-> obj y2))
(let ((v1-21 (+ (* (+ (the int (-> obj scroll y)) 208) 512) (-> s4-0 1))))
(bigmap-method-22 obj arg0 (+ (+ v1-21 16) (the-as int s4-0)) 8 512 208 (gs-psm mt8))
(texture-upload-dma obj arg0 (+ (+ v1-21 16) (the-as int s4-0)) 8 512 208 (gs-psm mt8))
)
)
(dma-buffer-add-gs-set arg0 (texflush 1))
(bigmap-method-26 obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(sprite-dma obj arg0 (-> obj x0) (-> obj y2) (-> obj x1) (-> obj y1))
(none)
)
;; definition for method 27 of type bigmap
;; INFO: Used lq/sq
(defmethod bigmap-method-27 bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
(defmethod draw-from-minimap bigmap ((obj bigmap) (arg0 dma-buffer) (arg1 connection-minimap))
(rlet ((vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
@@ -486,7 +493,7 @@
(not (load-in-progress? *level*))
)
(if (!= (-> obj bigmap-index) 20)
(bigmap-method-23 obj)
(mask-image-from-bit-mask obj)
)
(let ((s5-0 (-> *level* loading-level))
(s4-0 (-> *texture-pool* allocate-func))
@@ -514,10 +521,10 @@
(set! (-> obj offset quad) (-> *bigmap-info-array* data (-> obj mask-index) quad))
(when (!= (-> obj bigmap-index) (-> obj mask-index))
(if (!= (-> obj mask-index) 20)
(bigmap-method-19 obj)
(compress-current-masks! obj)
)
(set! (-> obj mask-index) (-> obj bigmap-index))
(bigmap-method-18 obj)
(decompress-current-masks! obj)
)
(when (!= (-> obj bigmap-index) (-> obj layer-index))
(set! (-> obj layer-index) (-> obj bigmap-index))
@@ -526,8 +533,8 @@
(the-as (pointer int8) (-> obj compressed-layers data (-> obj layer-index)))
)
)
(bigmap-method-17 obj (target-pos 0))
(bigmap-method-20 obj)
(set-pos! obj (target-pos 0))
(set-enable-from-position! obj)
(cond
((-> obj recording-flag)
(when (-> obj fill-flag)
@@ -535,7 +542,7 @@
(a2-5 (-> obj pos y))
)
(if (and (>= a1-9 0) (< a1-9 256) (>= a2-5 0) (< a2-5 208))
(bigmap-method-21 obj a1-9 a2-5)
(maybe-fill-for-position obj a1-9 a2-5)
)
)
)
@@ -556,7 +563,7 @@
(a2-6 (+ (-> obj pos y) s5-2))
)
(if (and (>= a1-10 0) (< a1-10 256) (>= a2-6 0) (< a2-6 208))
(bigmap-method-21 obj a1-10 a2-6)
(maybe-fill-for-position obj a1-10 a2-6)
)
)
(+! s3-1 1)
@@ -578,7 +585,7 @@
;; definition for method 11 of type bigmap
;; INFO: Used lq/sq
(defmethod bigmap-method-11 bigmap ((obj bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
(defmethod draw bigmap ((obj bigmap) (arg0 int) (arg1 int) (arg2 int) (arg3 int))
(local-vars (sv-96 pointer) (sv-100 texture) (sv-104 matrix) (sv-112 int))
(with-pp
(when (and (= (file-status (-> obj bigmap-image) "world-map" (the-as int (-> obj load-index))) 'active)
@@ -608,8 +615,8 @@
(clamp-1 (new 'static 'gs-clamp :wms (gs-tex-wrap-mode clamp) :wmt (gs-tex-wrap-mode clamp)))
)
(if (= (-> obj bigmap-index) 20)
(bigmap-method-25 obj s4-1)
(bigmap-method-24 obj s4-1)
(draw-city-map obj s4-1)
(draw-non-city-map obj s4-1)
)
)
(with-dma-buffer-add-bucket ((s4-2 (-> *display* frames (-> *display* on-screen) global-buf))
@@ -635,11 +642,11 @@
(when (logtest? (-> a2-3 class flags) (minimap-flag bigmap))
(cond
((= (-> obj bigmap-index) 20)
(bigmap-method-27 obj s4-2 a2-3)
(draw-from-minimap obj s4-2 a2-3)
)
(else
(if (not (logtest? (-> a2-3 class flags) (minimap-flag city-only)))
(bigmap-method-27 obj s4-2 a2-3)
(draw-from-minimap obj s4-2 a2-3)
)
)
)
@@ -660,7 +667,7 @@
(set! sv-104 (new 'stack-no-clear 'matrix))
(set! sv-112 (the int (* 56.0 f30-0)))
(when sv-100
(bigmap-method-17 obj (target-pos 0))
(set-pos! obj (target-pos 0))
(if (-> *blit-displays-work* horizontal-flip-flag)
(set! f30-0 (- f30-0))
)
@@ -742,7 +749,7 @@
;; definition for method 12 of type bigmap
;; INFO: Used lq/sq
(defmethod bigmap-method-12 bigmap ((obj bigmap))
(defmethod handle-cpad-inputs bigmap ((obj bigmap))
(cond
((= (-> obj bigmap-index) 20)
(let* ((v1-2 (-> *cpad-list* cpads 0))
@@ -760,9 +767,9 @@
)
;; definition for method 13 of type bigmap
(defmethod bigmap-method-13 bigmap ((obj bigmap))
(defmethod compress-all bigmap ((obj bigmap))
(when (!= (-> obj mask-index) 20)
(bigmap-method-19 obj)
(compress-current-masks! obj)
(set! (-> obj mask-index) (the-as uint 20))
)
0
@@ -771,11 +778,11 @@
;; definition for method 14 of type bigmap
;; INFO: Used lq/sq
;; WARN: Return type mismatch symbol vs none.
(defmethod bigmap-method-14 bigmap ((obj bigmap))
(defmethod enable-drawing bigmap ((obj bigmap))
(set! (-> obj bigmap-index) (the-as uint (-> (level-get-target-inside *level*) info bigmap-id)))
(cond
((= (-> obj bigmap-index) 20)
(bigmap-method-17 obj (target-pos 0))
(set-pos! obj (target-pos 0))
(set! (-> obj scroll y) (the float (max 0 (+ (* (-> obj pos y) 2) -208))))
(set-vector! (-> obj draw-offset) -2621440.0 -4456448.0 16384.0 0.000030517578)
(cond
@@ -813,7 +820,7 @@
)
;; definition for method 15 of type bigmap
(defmethod bigmap-method-15 bigmap ((obj bigmap))
(defmethod disable-drawing bigmap ((obj bigmap))
(set-pending-file
(-> obj bigmap-image)
(the-as string #f)
+6 -6
View File
@@ -480,7 +480,7 @@
(process-spawn hud-ring-cell 12 (* -2.0 f30-0) 8 :to self)
(process-spawn hud-ring-cell 11 (* -1.0 f30-0) 9 :to self)
)
(bigmap-method-14 *bigmap*)
(enable-drawing *bigmap*)
(go-virtual come-in)
)
@@ -546,7 +546,7 @@
;; definition for method 10 of type progress
(defmethod deactivate progress ((obj progress))
(remove-setting-by-arg0 *setting-control* 'extra-bank)
(bigmap-method-15 *bigmap*)
(disable-drawing *bigmap*)
(set! (-> *blit-displays-work* menu-mode) #f)
(set! *progress-process* (the-as (pointer progress) #f))
(enable-level-text-file-loading)
@@ -1480,7 +1480,7 @@
(when (and (< 0.8 (-> self anim-frame)) (or (= (-> self current) 'bigmap) (= (-> self next) 'bigmap)))
(cond
((>= (-> self pos-transition) 0.38)
(bigmap-method-11 *bigmap* 1792 1840 2304 2256)
(draw *bigmap* 1792 1840 2304 2256)
)
(else
(let ((s4-2 (vector<-cspace! (new 'stack-no-clear 'vector) (-> self node-list data 21)))
@@ -1491,7 +1491,7 @@
(let ((s5-1 (new 'stack-no-clear 'vector4w)))
(set! (-> s5-1 quad) (the-as uint128 0))
(if (and (transform-point-qword! gp-1 s4-2) (transform-point-qword! s5-1 s3-1))
(bigmap-method-11 *bigmap* (/ (-> s5-1 x) 16) (/ (-> s5-1 y) 16) (/ (-> gp-1 x) 16) (/ (-> gp-1 y) 16))
(draw *bigmap* (/ (-> s5-1 x) 16) (/ (-> s5-1 y) 16) (/ (-> gp-1 x) 16) (/ (-> gp-1 y) 16))
)
)
)
@@ -1819,7 +1819,7 @@
(defstate gone (progress)
:virtual #t
:code (behavior ()
(bigmap-method-15 *bigmap*)
(disable-drawing *bigmap*)
(set! (-> *blit-displays-work* menu-mode) #f)
(while (or (-> *blit-displays-work* screen-copied) (nonzero? (-> *blit-displays-work* count-down)))
(suspend)
@@ -3138,7 +3138,7 @@
;; definition for method 9 of type menu-bigmap-option
(defmethod respond-progress menu-bigmap-option ((obj menu-bigmap-option) (arg0 progress) (arg1 symbol))
"Handle progress menu navigation logic."
(bigmap-method-12 *bigmap*)
(handle-cpad-inputs *bigmap*)
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons confirm))
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons confirm))
0