diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 281db45696..0699db3688 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -5223,7 +5223,7 @@ (another-gray 17) (dark-dark-green 18) (flat-dark-purple 19) - (yellow 20) + (flat-yellow 20) (blue-white 21) (flat-dark-gray 22) (flat-gray 23) @@ -5235,9 +5235,29 @@ (yellow-orange 29) (yellow-green-2 30) (another-light-blue 31) - (another-default 32) + (light-yellow 32) (red-orange 33) (another-orange-red 34) + + (red 3) + (red2 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 10) + (red-reverse 33) + (red-obverse 34) + ) + +(defenum font-flags + :type uint32 + :bitfield #t + (shadow 0) + (kerning 1) + (middle 2) + (left 3) + (right 4) + (large 5) ) (deftype font-context (basic) @@ -5249,7 +5269,7 @@ (context-vec vector :inline :offset 48) ;; added (color font-color :offset-assert 64) (color-s32 int32 :offset 64) ;; added for asm - (flags uint32 :offset-assert 72) + (flags font-flags :offset-assert 72) (flags-signed int32 :offset 72) ;; added for asm (mat matrix :offset-assert 76) (start-line uint32 :offset-assert 80) @@ -5259,7 +5279,7 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float font-color uint) _type_ 0) + (new (symbol type matrix int int float font-color font-flags) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -5268,7 +5288,7 @@ (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) (set-color! (font-context font-color) font-context 16) - (set-flags! (font-context uint) font-context 17) + (set-flags! (font-context font-flags) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) ) @@ -5363,7 +5383,7 @@ (define-extern set-display-env (function display-env int int int int int int display-env)) (define-extern set-draw-env (function draw-env int int int int int int draw-env)) (define-extern get-video-mode (function symbol)) -(define-extern draw-string-xy (function string dma-buffer int int font-color int none)) +(define-extern draw-string-xy (function string dma-buffer int int font-color font-flags none)) (define-extern set-draw-env-offset (function draw-env int int int draw-env)) (define-extern put-display-alpha-env (function display-env none)) (define-extern set-display2 (function display int int int int int display)) diff --git a/game/graphics/gfx.cpp b/game/graphics/gfx.cpp index 53bc0d58a0..a4bc089019 100644 --- a/game/graphics/gfx.cpp +++ b/game/graphics/gfx.cpp @@ -30,8 +30,6 @@ void InitSettings(GfxSettings& settings) { // debug for now settings.debug = true; - // we're not setting controller info - settings.pad_mapping_info.input_mode = false; // use buffered input mode settings.pad_mapping_info.buffer_mode = true; // debug input settings @@ -129,6 +127,10 @@ void texture_relocate(u32 destination, u32 source, u32 format) { } } +void poll_events() { + g_settings.renderer->poll_events(); +} + int PadIsPressed(Pad::Button button, int port) { return Pad::IsPressed(g_settings.pad_mapping_info, button, port); } diff --git a/game/graphics/gfx.h b/game/graphics/gfx.h index 3b89a57c38..431090d0e5 100644 --- a/game/graphics/gfx.h +++ b/game/graphics/gfx.h @@ -32,6 +32,7 @@ struct GfxRendererModule { std::function send_chain; std::function texture_upload_now; std::function texture_relocate; + std::function poll_events; GfxPipeline pipeline; const char* name; @@ -68,6 +69,7 @@ u32 sync_path(); void send_chain(const void* data, u32 offset); void texture_upload_now(const u8* tpage, int mode, u32 s7_ptr); void texture_relocate(u32 destination, u32 source, u32 format); +void poll_events(); int PadIsPressed(Pad::Button button, int port); diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index e91b050698..b134df27e0 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -50,10 +50,10 @@ std::unique_ptr g_gfx_data; void SetDisplayCallbacks(GLFWwindow* d) { glfwSetKeyCallback(d, [](GLFWwindow* /*window*/, int key, int scancode, int action, int mods) { if (action == GlfwKeyAction::Press) { - lg::debug("KEY PRESS: key: {} scancode: {} mods: {:X}", key, scancode, mods); + // lg::debug("KEY PRESS: key: {} scancode: {} mods: {:X}", key, scancode, mods); Pad::OnKeyPress(key); } else if (action == GlfwKeyAction::Release) { - lg::debug("KEY RELEASE: key: {} scancode: {} mods: {:X}", key, scancode, mods); + // lg::debug("KEY RELEASE: key: {} scancode: {} mods: {:X}", key, scancode, mods); Pad::OnKeyRelease(key); } }); @@ -145,6 +145,9 @@ static void gl_kill_display(GfxDisplay* display) { static void gl_render_display(GfxDisplay* display) { GLFWwindow* window = display->window_glfw; + // poll events + glfwPollEvents(); + glfwMakeContextCurrent(window); // wait for a copied chain. @@ -182,10 +185,9 @@ static void gl_render_display(GfxDisplay* display) { { std::unique_lock lock(g_gfx_data->sync_mutex); g_gfx_data->frame_idx++; + g_gfx_data->sync_cv.notify_all(); } - // poll events TODO integrate input with cpad - glfwPollEvents(); // exit if display window was closed if (glfwWindowShouldClose(window)) { @@ -271,6 +273,10 @@ void gl_texture_relocate(u32 destination, u32 source, u32 format) { } } +void gl_poll_events() { + glfwPollEvents(); +} + const GfxRendererModule moduleOpenGL = { gl_init, // init gl_make_main_display, // make_main_display @@ -282,6 +288,7 @@ const GfxRendererModule moduleOpenGL = { gl_send_chain, // send_chain gl_texture_upload_now, // texture_upload_now gl_texture_relocate, // texture_relocate + gl_poll_events, // poll_events GfxPipeline::OpenGL, // pipeline "OpenGL 3.0" // name }; diff --git a/game/kernel/kmachine.cpp b/game/kernel/kmachine.cpp index 6f61f62ded..30cc6dd578 100644 --- a/game/kernel/kmachine.cpp +++ b/game/kernel/kmachine.cpp @@ -36,6 +36,7 @@ #include "game/graphics/dma/dma_copy.h" #include "game/system/vm/vm.h" +#include "game/system/newpad.h" using namespace ee; /*! @@ -423,8 +424,7 @@ u64 CPadOpen(u64 cpad_info, s32 pad_number) { return cpad_info; } -// TODO CPadGetData -Ptr CPadGetData(u64 cpad_info) { +u64 CPadGetData(u64 cpad_info) { auto cpad = Ptr(cpad_info).c(); auto pad_state = scePadGetState(cpad->number, 0); if (pad_state == scePadStateDiscon) { @@ -472,7 +472,7 @@ Ptr CPadGetData(u64 cpad_info) { if (scePadInfoMode(cpad->number, 0, InfoModeIdTable, -1) == 0) { // no controller modes cpad->state = 90; - return make_ptr(cpad); + return cpad_info; } cpad->state = 41; case 41: // controller mode - change to dualshock mode! @@ -530,7 +530,7 @@ Ptr CPadGetData(u64 cpad_info) { case 90: break; // unsupported controller. too bad! } - return make_ptr(cpad); + return cpad_info; } // TODO InstallHandler @@ -715,6 +715,16 @@ void InitMachine_PCPort() { make_function_symbol_from_c("__send-gfx-dma-chain", (void*)send_gfx_dma_chain); make_function_symbol_from_c("__pc-texture-upload-now", (void*)pc_texture_upload_now); make_function_symbol_from_c("__pc-texture-relocate", (void*)pc_texture_relocate); + + // pad stuff + make_function_symbol_from_c("pc-pad-input-mode-set", (void*)Pad::input_mode_set); + make_function_symbol_from_c("pc-pad-input-mode-get", (void*)Pad::input_mode_get); + + // init ps2 VM + if (VM::use) { + make_function_symbol_from_c("vm-ptr", (void*)VM::get_vm_ptr); + VM::vm_init(); + } } void vif_interrupt_callback() { diff --git a/game/kernel/kscheme.cpp b/game/kernel/kscheme.cpp index b6084d79a4..3e1d29ccfa 100644 --- a/game/kernel/kscheme.cpp +++ b/game/kernel/kscheme.cpp @@ -24,8 +24,6 @@ #include "common/log/log.h" #include "common/util/Timer.h" -#include "game/system/vm/vm.h" - //! Controls link mode when EnableMethodSet = 0, MasterDebug = 1, DiskBoot = 0. Will enable a //! warning message if EnableMethodSet = 1 u32 FastLink; @@ -1966,12 +1964,6 @@ s32 InitHeapAndSymbol() { // set *boot-video-mode* intern_from_c("*boot-video-mode*")->value = 0; - // OpenGOAL only - init ps2 VM - if (VM::use) { - make_function_symbol_from_c("vm-ptr", (void*)VM::get_vm_ptr); - VM::vm_init(); - } - lg::info("Initialized GOAL heap in {:.2} ms", heap_init_timer.getMs()); // load the kernel! // todo, remove MasterUseKernel diff --git a/game/sce/libpad.cpp b/game/sce/libpad.cpp index 5a61cd9175..fb5a0fe1de 100644 --- a/game/sce/libpad.cpp +++ b/game/sce/libpad.cpp @@ -63,6 +63,7 @@ static const Pad::Button libpad_PadPressureButtons[] = { // returns buffer size (32) or 0 on error. int scePadRead(int port, int slot, u8* rdata) { auto cpad = (CPadInfo*)(rdata); + Gfx::poll_events(); cpad->valid = 0; // success diff --git a/game/system/newpad.cpp b/game/system/newpad.cpp index 834b962b20..0a5ec76e5b 100644 --- a/game/system/newpad.cpp +++ b/game/system/newpad.cpp @@ -8,6 +8,7 @@ #include "common/log/log.h" #include "game/graphics/pipelines/opengl.h" // for GLFW macros +#include "game/kernel/kscheme.h" namespace Pad { @@ -20,21 +21,32 @@ namespace Pad { std::unordered_map g_key_status; std::unordered_map g_buffered_key_status; +// input mode for controller mapping +bool input_mode = false; +u64 input_mode_key = -1; +u64 input_mode_mod = 0; + void ForceClearKeys() { g_key_status.clear(); g_buffered_key_status.clear(); } void ClearKeys() { + g_buffered_key_status.clear(); for (auto& key : g_key_status) { - key.second = false; - } - for (auto& key : g_buffered_key_status) { - key.second = false; + g_buffered_key_status.insert(std::make_pair(key.first, key.second)); } } void OnKeyPress(int key) { + if (input_mode) { + if (key == GLFW_KEY_ESCAPE) { + input_mode = false; + return; + } + input_mode_key = key; + return; + } // set absolute key status if (g_key_status.find(key) == g_key_status.end()) { g_key_status.insert(std::make_pair(key, 1)); @@ -51,6 +63,9 @@ void OnKeyPress(int key) { } void OnKeyRelease(int key) { + if (input_mode) { + return; + } // set absolute key status // no bounds checking for now in order to catch bugs g_key_status.at(key) = 0; @@ -111,4 +126,16 @@ void DefaultMapping(MappingInfo& mapping) { MapButton(mapping, Button::Left, 0, GLFW_KEY_LEFT); } +void input_mode_set(u32 enable) { + if (enable != s7.offset) { + input_mode = true; + } else { + input_mode = false; + } +} + +u64 input_mode_get() { + return input_mode_key; +} + }; // namespace Pad diff --git a/game/system/newpad.h b/game/system/newpad.h index 0514b48c9f..a2cd77cc89 100644 --- a/game/system/newpad.h +++ b/game/system/newpad.h @@ -14,6 +14,7 @@ */ #include +#include "common/common_types.h" namespace Pad { @@ -50,9 +51,9 @@ enum class Button { }; struct MappingInfo { - bool debug = true; // debug mode - bool input_mode = false; // input mode for controller mapping - bool buffer_mode = true; // use buffered inputs + bool debug = true; // debug mode + bool buffer_mode = true; // use buffered inputs + int pad_mapping[CONTROLLER_COUNT][(int)Pad::Button::Max]; // controller button mapping // TODO complex button mapping & key macros (e.g. shift+x for l2+r2 press etc.) }; @@ -71,4 +72,7 @@ void DefaultMapping(MappingInfo& mapping); int IsPressed(MappingInfo& mapping, Button button, int pad); void MapButton(MappingInfo& mapping, Button button, int pad, int key); +void input_mode_set(u32 enable); +u64 input_mode_get(); + } // namespace Pad diff --git a/goal_src/engine/debug/debug.gc b/goal_src/engine/debug/debug.gc index ca97504b89..60bef85c49 100644 --- a/goal_src/engine/debug/debug.gc +++ b/goal_src/engine/debug/debug.gc @@ -214,7 +214,7 @@ ) 0.0 font-color-id - (the-as uint 3) + (font-flags shadow kerning) ))) (let ((v1-9 a2-2)) (set! (-> v1-9 origin z) (the float (/ (-> s2-0 z) 16))) diff --git a/goal_src/engine/debug/menu.gc b/goal_src/engine/debug/menu.gc index c178378b7d..3e3883ebb4 100644 --- a/goal_src/engine/debug/menu.gc +++ b/goal_src/engine/debug/menu.gc @@ -38,7 +38,7 @@ (set! (-> gp-0 root-menu) #f) (set! (-> gp-0 joypad-func) #f) (set! (-> gp-0 joypad-item) #f) - (set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (the-as uint 3))) + (set! (-> gp-0 font) (new 'debug 'font-context *font-default-matrix* 0 0 0.0 (font-color default) (font-flags shadow kerning))) gp-0 ) ) diff --git a/goal_src/engine/game/main.gc b/goal_src/engine/game/main.gc index 18983ed3ee..ebf5babe2e 100644 --- a/goal_src/engine/game/main.gc +++ b/goal_src/engine/game/main.gc @@ -1146,7 +1146,7 @@ (when *display-deci-count* (let ((s2-1 draw-string-xy)) (format (clear *temp-string*) "~D" *deci-count*) - (s2-1 *temp-string* debug-buf 448 210 (font-color default) 3) + (s2-1 *temp-string* debug-buf 448 210 (font-color default) (font-flags shadow kerning)) ) ) @@ -1183,7 +1183,7 @@ (if (= *master-mode* 'pause) (draw-string-xy (lookup-text! *common-text* (game-text-id pause) #f) - s3-1 256 160 (font-color orange-red) 39) + s3-1 256 160 (font-color orange-red) (font-flags shadow kerning middle large)) ) ;; draw console text on screen @@ -1193,7 +1193,7 @@ (the int (-> *font-context* origin x)) a3-8 (font-color default) - 3 + (font-flags shadow kerning) ) ) @@ -1277,14 +1277,8 @@ ) ) (set! *run* #t) - ;; this is actually a macro (see logic-target.gc) - (let ((new-dproc (swhen (get-process *4k-dead-pool* process (* 16 1024)) - ((method-of-type process activate) bc *display-pool* 'display *kernel-dram-stack*) - ((the (function cpu-thread function object) set-to-run) (-> bc main-thread) display-loop) - (-> bc ppointer) - )) - ) - (set! *dproc* (the process (if new-dproc (-> new-dproc 0 self)))) + (let ((new-dproc (make-function-process *4k-dead-pool* *display-pool* process 'display display-loop))) + (set! *dproc* (the process (as-process new-dproc))) ) (cond ((or (level-get-with-status *level* 'loaded) diff --git a/goal_src/engine/gfx/font-h.gc b/goal_src/engine/gfx/font-h.gc index d8f49ed058..4ab76e8e1c 100644 --- a/goal_src/engine/gfx/font-h.gc +++ b/goal_src/engine/gfx/font-h.gc @@ -8,14 +8,6 @@ ;; The font system draws all of the strings. ;; The font textures live in the upper 8 bits of the 24-bit texture format depth buffer. -;; flags -;; 1 -;; 2 -;; 4 -;; 8 -;; 16 -;; 32 (use size 24) - (defenum font-color :type uint64 (default 0) @@ -38,7 +30,7 @@ (another-gray 17) (dark-dark-green 18) (flat-dark-purple 19) - (yellow 20) + (flat-yellow 20) (blue-white 21) (flat-dark-gray 22) (flat-gray 23) @@ -50,9 +42,29 @@ (yellow-orange 29) (yellow-green-2 30) (another-light-blue 31) - (another-default 32) + (light-yellow 32) (red-orange 33) (another-orange-red 34) + + (red 3) + (red2 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 10) + (red-reverse 33) + (red-obverse 34) + ) + +(defenum font-flags + :type uint32 + :bitfield #t + (shadow 0) + (kerning 1) + (middle 2) + (left 3) + (right 4) + (large 5) ) (deftype char-verts (structure) @@ -92,7 +104,7 @@ (context-vec vector :inline :offset 48) ;; added (color font-color :offset-assert 64) (color-s32 int32 :offset 64) ;; added for asm - (flags uint32 :offset-assert 72) + (flags font-flags :offset-assert 72) (flags-signed int32 :offset 72) ;; added for asm (mat matrix :offset-assert 76) (start-line uint32 :offset-assert 80) @@ -102,7 +114,7 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float font-color uint) _type_ 0) + (new (symbol type matrix int int float font-color font-flags) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -111,7 +123,7 @@ (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) (set-color! (font-context font-color) font-context 16) - (set-flags! (font-context uint) font-context 17) + (set-flags! (font-context font-flags) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) ) @@ -176,7 +188,7 @@ obj ) -(defmethod set-flags! font-context ((obj font-context) (flags uint)) +(defmethod set-flags! font-context ((obj font-context) (flags font-flags)) (declare (inline)) (set! (-> obj flags) flags) @@ -197,7 +209,7 @@ obj ) -(defmethod new font-context ((allocation symbol) (type-to-make type) (mat matrix) (x int) (y int) (z float) (color font-color) (flags uint)) +(defmethod new font-context ((allocation symbol) (type-to-make type) (mat matrix) (x int) (y int) (z float) (color font-color) (flags font-flags)) (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))) @@ -280,7 +292,7 @@ (buf basic :offset-assert 3024) (str-ptr uint32 :offset-assert 3028) (str-ptr-signed (pointer uint8) :offset 3028) ;; added - (flags uint32 :offset-assert 3032) + (flags font-flags :offset-assert 3032) (flags-signed int32 :offset 3032) ;; added (reg-save uint32 5 :offset-assert 3036) ) @@ -750,4 +762,4 @@ (define-extern draw-string (function string dma-buffer font-context float)) -(define-extern draw-string-xy (function string dma-buffer int int font-color int none)) \ No newline at end of file +(define-extern draw-string-xy (function string dma-buffer int int font-color font-flags none)) \ No newline at end of file diff --git a/goal_src/engine/gfx/font.gc b/goal_src/engine/gfx/font.gc index 4969f9ae64..3c8aefc303 100644 --- a/goal_src/engine/gfx/font.gc +++ b/goal_src/engine/gfx/font.gc @@ -826,7 +826,7 @@ (.mov.vf vf2 vf0) (.mov.vf vf3 vf0) (.mov.vf vf4 vf0) - (set! (-> fw flags) (the-as uint flags)) + (set! (-> fw flags) (the-as font-flags flags)) (.lvf vf16 (&-> fw size-st1 quad)) (.lvf vf17 (&-> fw size-st2 quad)) (.lvf vf18 (&-> fw size-st3 quad)) @@ -2081,7 +2081,7 @@ (.mul.vf vf24 vf24 vf1 :mask #b11) (let ((a1-4 *font-work*)) (set! (-> a1-4 str-ptr) (the-as uint arg0)) - (set! (-> a1-4 flags) (the-as uint v1-0)) + (set! (-> a1-4 flags) (the-as font-flags v1-0)) (.mov.vf vf1 vf0) (let ((a2-0 (logand v1-0 32))) (nop!) @@ -2231,7 +2231,7 @@ ) ) -(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 font-color) (arg5 int)) +(defun draw-string-xy ((arg0 string) (arg1 dma-buffer) (arg2 int) (arg3 int) (arg4 font-color) (arg5 font-flags)) ;(format #t "call to ds: ~A~%" arg0) (let ((a2-2 (new 'stack 'font-context *font-default-matrix* @@ -2239,7 +2239,7 @@ arg3 0.0 arg4 - (the-as uint arg5) + arg5 ) ) ) diff --git a/goal_src/engine/gfx/hw/display.gc b/goal_src/engine/gfx/hw/display.gc index 62e59dd448..aa255dac85 100644 --- a/goal_src/engine/gfx/hw/display.gc +++ b/goal_src/engine/gfx/hw/display.gc @@ -280,8 +280,8 @@ ) -(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 (font-color default) (the uint 3))) -(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 (font-color orange-red) (the uint 3))) +(define *font-context* (new 'global 'font-context *font-default-matrix* 0 24 0.0 (font-color default) (font-flags shadow kerning))) +(define *pause-context* (new 'global 'font-context *font-default-matrix* 256 170 0.0 (font-color orange-red) (font-flags shadow kerning))) @@ -410,7 +410,7 @@ (cond (*profile-ticks* (draw-string-xy (string-format "~5D" (-> worst-time-cache (/ bar-pos 10))) - buf 488 (+ bar-pos 8) (font-color default) 17) + buf 488 (+ bar-pos 8) (font-color default) (font-flags shadow right)) (the float (-> worst-time-cache (/ bar-pos 10))) ) (else @@ -423,7 +423,7 @@ ))) (draw-string-xy (string-format "~5,,2f" f30-0) buf 488 (+ bar-pos 8) (if (>= f30-0 100.0) (font-color orange-red) (font-color default)) ;; turn red if over 100. - 17 + (font-flags shadow right) ) f30-0 ) diff --git a/goal_src/engine/ps2/memcard-h.gc b/goal_src/engine/ps2/memcard-h.gc index 90c6518773..45f0ee802d 100644 --- a/goal_src/engine/ps2/memcard-h.gc +++ b/goal_src/engine/ps2/memcard-h.gc @@ -93,7 +93,7 @@ ) ) ) - (draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color orange-red) 1) + (draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color orange-red) (font-flags shadow)) ) ) (none) diff --git a/goal_src/engine/sound/gsound.gc b/goal_src/engine/sound/gsound.gc index 993bc02200..56d90b212b 100644 --- a/goal_src/engine/sound/gsound.gc +++ b/goal_src/engine/sound/gsound.gc @@ -734,12 +734,12 @@ (dotimes (ch 24) (draw-string-xy (if (zero? (-> *sound-iop-info* chinfo ch)) "." "X") - buf (+ (* ch 16) 16) 48 (font-color default) 1) + buf (+ (* ch 16) 16) 48 (font-color default) (font-flags shadow)) ) (dotimes (ch 24) (draw-string-xy (if (zero? (-> *sound-iop-info* chinfo (+ ch 24))) "." "X") - buf (+ (* ch 16) 16) 64 (font-color default) 1) + buf (+ (* ch 16) 16) 64 (font-color default) (font-flags shadow)) ) 0 ) @@ -748,11 +748,11 @@ (draw-string-xy (string-format "~8D [~4D]" (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10)) - buf 32 96 (font-color default) 1) + buf 32 96 (font-color default) (font-flags shadow)) (draw-string-xy (string-format "~8D [~4D]" (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10)) - buf 32 64 (font-color default) 1) + buf 32 64 (font-color default) (font-flags shadow)) 0 ) diff --git a/goal_src/engine/target/logic-target.gc b/goal_src/engine/target/logic-target.gc index 349829350f..feec857c14 100644 --- a/goal_src/engine/target/logic-target.gc +++ b/goal_src/engine/target/logic-target.gc @@ -32,14 +32,7 @@ (set! (-> *level* border?) #f) (set! (-> *setting-control* default border-mode) #f) (stop game-mode) - ;; this is also that same macro... i just have no idea how to write it. - (let* ((s5-0 (the target (get-process *target-dead-pool* target #x4000))) - (v1-3 (when s5-0 - ((method-of-type target activate) s5-0 *target-pool* 'target *kernel-dram-stack*) - ((the (function object object object object) run-function-in-process) s5-0 init-target cont) - (-> s5-0 ppointer) - )) - ) + (let ((v1-3 (make-function-process *target-dead-pool* *target-pool* target 'target init-target cont))) (if v1-3 (set! *target* (the target (-> v1-3 0 self))) (set! *target* #f) diff --git a/goal_src/engine/ui/credits.gc b/goal_src/engine/ui/credits.gc index ce918151ef..8e2b7711e0 100644 --- a/goal_src/engine/ui/credits.gc +++ b/goal_src/engine/ui/credits.gc @@ -60,7 +60,7 @@ 0 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) ) @@ -71,7 +71,7 @@ (let ((v1-4 gp-0)) (set! (-> v1-4 height) (the float 10)) ) - (set! (-> gp-0 flags) (the-as uint 38)) + (set! (-> gp-0 flags) (font-flags kerning middle large)) (let* ((s5-1 (- s5-0 (mod s5-0 3))) (f0-10 (- f30-0 (the float s5-1))) ) @@ -137,7 +137,7 @@ (gp-0 2815) (s3-0 0) (s2-0 #t) - (s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 (font-color default) (the-as uint 3))) + (s5-0 (new 'stack 'font-context *font-default-matrix* 31 0 0.0 (font-color default) (font-flags shadow kerning))) ) (let ((v1-2 s5-0)) (set! (-> v1-2 width) (the float 450)) @@ -148,7 +148,7 @@ (let ((v1-4 s5-0)) (set! (-> v1-4 scale) 1.0) ) - (set! (-> s5-0 flags) (the-as uint 39)) + (set! (-> s5-0 flags) (font-flags shadow kerning middle large)) (while (or s2-0 (and (< s4-0 (- s3-0)) (< (the-as uint gp-0) (the-as uint 3249)))) (+! s4-0 s3-0) (+! gp-0 1) diff --git a/goal_src/engine/ui/text.gc b/goal_src/engine/ui/text.gc index 6b1e19283a..8a53fb2c10 100644 --- a/goal_src/engine/ui/text.gc +++ b/goal_src/engine/ui/text.gc @@ -437,7 +437,7 @@ (the int (-> font-ctxt origin y)) 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) ) @@ -453,8 +453,8 @@ (set! (-> gp-0 flags) (-> font-ctxt flags)) (set! (-> gp-0 color) (-> font-ctxt color)) (set! (-> gp-0 scale) sv-136) - (when (logtest? (-> gp-0 flags) 8) - (set! (-> gp-0 flags) (logand -9 (-> gp-0 flags))) + (when (logtest? (-> gp-0 flags) (font-flags left)) + (logclear! (-> gp-0 flags) (font-flags left)) (let ((f30-0 (-> gp-0 width)) (f28-0 (-> gp-0 height)) ) diff --git a/goal_src/examples/debug-draw-example.gc b/goal_src/examples/debug-draw-example.gc index 1c045dc74c..a5a50b08ac 100644 --- a/goal_src/examples/debug-draw-example.gc +++ b/goal_src/examples/debug-draw-example.gc @@ -1,3 +1,6 @@ +;;-*-Lisp-*- +(in-package goal) + ;; This file demonstrates how to use the debug draw. ;; To run this: diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index 358e57931d..e474ed451d 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -148,13 +148,11 @@ ;; gs-get-imr (define-extern gs-store-image (function object object object)) (define-extern flush-cache (function int none)) -;; cpad-open (declare-type cpad-info basic) (define-extern cpad-open (function cpad-info int cpad-info)) (define-extern cpad-get-data (function cpad-info cpad-info)) (define-extern install-handler (function int (function int) int)) ;; check return val ;; install-debug-handler -;; file-stream-open (define-extern file-stream-open (function file-stream basic basic file-stream)) (define-extern file-stream-close (function file-stream file-stream)) (define-extern file-stream-length (function file-stream int)) @@ -178,13 +176,6 @@ ;; *kernel-boot-mode* ;; *kernel-boot-level* -;; PC Port functions -(define-extern __read-ee-timer (function uint)) -(define-extern __mem-move (function pointer pointer uint none)) -(define-extern __send-gfx-dma-chain (function object object none)) -(define-extern __pc-texture-upload-now (function object object none)) -(define-extern __pc-texture-relocate (function object object object none)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ksound - InitSoundScheme ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -269,6 +260,15 @@ :no-runtime-type ;; already constructed, don't do it again. ) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; PC Port functions +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define-extern __read-ee-timer (function uint)) +(define-extern __mem-move (function pointer pointer uint none)) +(define-extern __send-gfx-dma-chain (function object object none)) +(define-extern __pc-texture-upload-now (function object object none)) +(define-extern __pc-texture-relocate (function object object object none)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; vm functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/kernel/gkernel-h.gc b/goal_src/kernel/gkernel-h.gc index b9e9ec2559..023742fd1f 100644 --- a/goal_src/kernel/gkernel-h.gc +++ b/goal_src/kernel/gkernel-h.gc @@ -455,7 +455,7 @@ ) -;; Not sure what this is, but it's probably used in the event system. +;; this is used for the event system to pass around parameters from one process to another. (deftype event-message-block (structure) ((to process :offset-assert 0) (from process :offset-assert 4) diff --git a/goal_src/kernel/gstate.gc b/goal_src/kernel/gstate.gc index cc1300809f..28c4c4852a 100644 --- a/goal_src/kernel/gstate.gc +++ b/goal_src/kernel/gstate.gc @@ -80,6 +80,20 @@ There are several ways to "go" ) ) +(defmacro make-function-process (dead-pool new-pool proc-type proc-name func &key (stack-size #x4000) &key (stack *kernel-dram-stack*) &rest args) + "Start a new process that runs a function on its main thread. Returns a pointer to the new process (or #f)." + + (with-gensyms (new-proc) + `(let ((,new-proc (get-process ,dead-pool ,proc-type ,stack-size))) + (when ,new-proc + ((method-of-type ,proc-type activate) (the-as ,proc-type ,new-proc) ,new-pool ,proc-name ,stack) + (run-now-in-process ,new-proc ,func ,@args) + (-> ,new-proc ppointer) + ) + ) + ) + ) + ;; display a listing of active processes. (defmacro ps (&key (detail #f)) `(inspect-process-tree *active-pool* 0 0 ,detail) diff --git a/goal_src/pc_debug/pc-pad-utils.gc b/goal_src/pc_debug/pc-pad-utils.gc new file mode 100644 index 0000000000..66247dc3cf --- /dev/null +++ b/goal_src/pc_debug/pc-pad-utils.gc @@ -0,0 +1,100 @@ +;;-*-Lisp-*- +(in-package goal) + + +;; This file is used for debugging and testing the PC port pad (controller/input) implementation. +;; It contains a function for creating a process for debugging cpad inputs and a function to kill that process. +;; It also contains a function to start a process to map keys to cpad inputs (X, circle, etc.), and another one to kill it. +;; THIS FILE IS DEBUG ONLY and will not work if *debug-segment* is not enabled. + +;; To run this: + +#| +(make-group "iso") ;; build the game +(lt) ;; connect to the runtime +(lg) ;; have the runtime load the game engine +(test-play) ;; start the game loop +(ml "goal_src/pc_debug/pc-pad-utils.gc") ;; build and load this file. +|# + +(if *debug-segment* (begin + +(define *pc-pad-show-proc* (the handle #f)) +(define *pc-pad-input-proc* (the handle #f)) + +(defun-debug pc-pad-show-start () + "Start the PC port pad debug display" + + (if (not (handle->process *pc-pad-show-proc*)) + (set! *pc-pad-show-proc* (ppointer->handle + (make-function-process *nk-dead-pool* *active-pool* process 'pc-pad-show + (lambda :behavior process () + (stack-size-set! (-> self main-thread) 512) + (loop + (let ((cpad (-> *cpad-list* cpads 0))) + (format *stdcon* "~3Lcpad 0~%~0L") + (format *stdcon* "~Tbutton0: ~X~%" (-> cpad button0)) + (format *stdcon* "~Tbutton0-abs 0: ~X~%" (-> cpad button0-abs 0)) + (format *stdcon* "~Tbutton0-abs 1: ~X~%" (-> cpad button0-abs 1)) + (format *stdcon* "~Tbutton0-abs 2: ~X~%" (-> cpad button0-abs 2)) + (format *stdcon* "~Tbutton0-rel 0: ~X~%" (-> cpad button0-rel 0)) + (format *stdcon* "~Tbutton0-rel 1: ~X~%" (-> cpad button0-rel 1)) + (format *stdcon* "~Tbutton0-rel 2: ~X~%" (-> cpad button0-rel 2)) + ) + (suspend) + ) + ) + ) + )) + + (format #t "That process is already running. :-)") + ) + ) + +(defun-debug pc-pad-show-stop () + "Stop the PC port pad debug display" + + (kill-by-name 'pc-pad-show *active-pool*) + ) + +(defun-debug pc-pad-input-start () + "Start the PC port pad debug key mapping" + + (if (not (handle->process *pc-pad-input-proc*)) + (set! *pc-pad-input-proc* (ppointer->handle + (make-function-process *nk-dead-pool* *active-pool* process 'pc-pad-input + (lambda :behavior process () + (stack-size-set! (-> self main-thread) 512) + (let ((start-time (get-current-time)) + (time-passed 0)) + (loop + (set! time-passed (- (the int (get-current-time)) start-time)) + + (with-dma-buffer-add-bucket ((buf (current-display-frame debug-buf)) + (current-display-frame bucket-group) + (bucket-id debug-draw1)) + (if (< (mod time-passed (seconds 2)) (seconds 1)) + (draw-string-xy "NOW MAPPING PAD" buf 256 64 (font-color red) (font-flags shadow kerning large middle)) + ) + + ) + + (suspend) + ) + ) + ) + ) + )) + + (format #t "That process is already running. :-)") + ) + ) + +(defun-debug pc-pad-input-stop () + "Stop the PC port pad debug key mapping" + + (kill-by-name 'pc-pad-input *active-pool*) + ) + +) +(format #t "No debug memory in use. pc-pad-utils not loaded.")) \ No newline at end of file diff --git a/test/decompiler/reference/engine/debug/debug_REF.gc b/test/decompiler/reference/engine/debug/debug_REF.gc index 2cb4169d05..7d4c298cd5 100644 --- a/test/decompiler/reference/engine/debug/debug_REF.gc +++ b/test/decompiler/reference/engine/debug/debug_REF.gc @@ -422,7 +422,7 @@ ) 0.0 arg3 - (the-as uint 3) + (font-flags shadow kerning) ) ) ) diff --git a/test/decompiler/reference/engine/debug/menu_REF.gc b/test/decompiler/reference/engine/debug/menu_REF.gc index f283695fd7..35b59e3c16 100644 --- a/test/decompiler/reference/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/engine/debug/menu_REF.gc @@ -59,7 +59,7 @@ 0 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) gp-0 diff --git a/test/decompiler/reference/engine/gfx/font-h_REF.gc b/test/decompiler/reference/engine/gfx/font-h_REF.gc index 4fad551113..5e5a10ec5e 100644 --- a/test/decompiler/reference/engine/gfx/font-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/font-h_REF.gc @@ -61,7 +61,7 @@ (context-vec vector :inline :offset 48) (color font-color :offset-assert 64) (color-s32 int32 :offset 64) - (flags uint32 :offset-assert 72) + (flags font-flags :offset-assert 72) (flags-signed int32 :offset 72) (mat matrix :offset-assert 76) (start-line uint32 :offset-assert 80) @@ -71,7 +71,7 @@ :size-assert #x58 :flag-assert #x1400000058 (:methods - (new (symbol type matrix int int float font-color uint) _type_ 0) + (new (symbol type matrix int int float font-color font-flags) _type_ 0) (set-mat! (font-context matrix) font-context 9) (set-origin! (font-context int int) font-context 10) (set-depth! (font-context int) font-context 11) @@ -80,7 +80,7 @@ (set-height! (font-context int) font-context 14) (set-projection! (font-context float) font-context 15) (set-color! (font-context font-color) font-context 16) - (set-flags! (font-context uint) font-context 17) + (set-flags! (font-context font-flags) font-context 17) (set-start-line! (font-context uint) font-context 18) (set-scale! (font-context float) font-context 19) ) @@ -152,7 +152,7 @@ ) ;; definition for method 17 of type font-context -(defmethod set-flags! font-context ((obj font-context) (flags uint)) +(defmethod set-flags! font-context ((obj font-context) (flags font-flags)) (set! (-> obj flags) flags) obj ) @@ -180,7 +180,7 @@ (y int) (z float) (color font-color) - (flags uint) + (flags font-flags) ) (let ((obj diff --git a/test/decompiler/reference/engine/gfx/hw/display_REF.gc b/test/decompiler/reference/engine/gfx/hw/display_REF.gc index bce48f0cec..b53dcc27a6 100644 --- a/test/decompiler/reference/engine/gfx/hw/display_REF.gc +++ b/test/decompiler/reference/engine/gfx/hw/display_REF.gc @@ -267,7 +267,7 @@ 24 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) @@ -282,7 +282,7 @@ 170 0.0 (font-color orange-red) - (the-as uint 3) + (font-flags shadow kerning) ) ) @@ -466,7 +466,14 @@ (*profile-ticks* (let ((s3-0 draw-string-xy)) (format (clear *temp-string*) "~5D" (-> worst-time-cache (/ bar-pos 10))) - (s3-0 *temp-string* buf 488 (+ bar-pos 8) (font-color default) 17) + (s3-0 + *temp-string* + buf + 488 + (+ bar-pos 8) + (font-color default) + (font-flags shadow right) + ) ) (the float (-> worst-time-cache (/ bar-pos 10))) ) @@ -491,7 +498,7 @@ 0 ) ) - 17 + (font-flags shadow right) ) ) f30-0 diff --git a/test/decompiler/reference/engine/nav/navigate-h_REF.gc b/test/decompiler/reference/engine/nav/navigate-h_REF.gc index 5c35f8601c..e75a2bad6f 100644 --- a/test/decompiler/reference/engine/nav/navigate-h_REF.gc +++ b/test/decompiler/reference/engine/nav/navigate-h_REF.gc @@ -591,7 +591,7 @@ (defmethod should-display? nav-control ((obj nav-control)) (and *display-nav-marks* - (nonzero? (logand (-> obj flags) (nav-control-flags bit0 display-marks))) + (nonzero? (logand (-> obj flags) (nav-control-flags display-marks bit0))) ) ) diff --git a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc index 0719980874..726dc997ba 100644 --- a/test/decompiler/reference/engine/ps2/memcard-h_REF.gc +++ b/test/decompiler/reference/engine/ps2/memcard-h_REF.gc @@ -148,7 +148,7 @@ 32 (+ (* 12 slot-idx) 8) (font-color orange-red) - 1 + (font-flags shadow) ) ) ) diff --git a/test/decompiler/reference/engine/sound/gsound_REF.gc b/test/decompiler/reference/engine/sound/gsound_REF.gc index 7f918ee495..070eb688cc 100644 --- a/test/decompiler/reference/engine/sound/gsound_REF.gc +++ b/test/decompiler/reference/engine/sound/gsound_REF.gc @@ -1022,7 +1022,7 @@ (+ (* s5-0 16) 16) 48 (font-color default) - 1 + (font-flags shadow) ) ) (dotimes (s5-1 24) @@ -1034,7 +1034,7 @@ (+ (* s5-1 16) 16) 64 (font-color default) - 1 + (font-flags shadow) ) ) 0 @@ -1049,7 +1049,7 @@ (-> *sound-iop-info* freemem) (shr (-> *sound-iop-info* freemem) 10) ) - (s5-0 *temp-string* arg0 32 96 (font-color default) 1) + (s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow)) ) (let ((s5-1 draw-string-xy)) (format @@ -1058,7 +1058,7 @@ (-> *sound-iop-info* freemem2) (shr (-> *sound-iop-info* freemem2) 10) ) - (s5-1 *temp-string* arg0 32 64 (font-color default) 1) + (s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow)) ) 0 ) diff --git a/test/decompiler/reference/engine/ui/credits_REF.gc b/test/decompiler/reference/engine/ui/credits_REF.gc index a7956d0c2f..b4e69cfe48 100644 --- a/test/decompiler/reference/engine/ui/credits_REF.gc +++ b/test/decompiler/reference/engine/ui/credits_REF.gc @@ -85,7 +85,7 @@ 0 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) ) @@ -96,7 +96,7 @@ (let ((v1-4 gp-0)) (set! (-> v1-4 height) (the float 10)) ) - (set! (-> gp-0 flags) (the-as uint 38)) + (set! (-> gp-0 flags) (font-flags kerning middle large)) (let* ((s5-1 (- s5-0 (mod s5-0 3))) (f0-10 (- f30-0 (the float s5-1))) ) @@ -173,7 +173,7 @@ 0 0.0 (font-color default) - (the-as uint 3) + (font-flags shadow kerning) ) ) ) @@ -186,7 +186,7 @@ (let ((v1-4 s5-0)) (set! (-> v1-4 scale) 1.0) ) - (set! (-> s5-0 flags) (the-as uint 39)) + (set! (-> s5-0 flags) (font-flags shadow kerning middle large)) (while (or s2-0 (and (< s4-0 (- s3-0)) (< (the-as uint gp-0) (the-as uint 3249)))) (+! s4-0 s3-0) diff --git a/test/decompiler/reference/levels/common/nav-enemy_REF.gc b/test/decompiler/reference/levels/common/nav-enemy_REF.gc index e088a084a6..40f53811d2 100644 --- a/test/decompiler/reference/levels/common/nav-enemy_REF.gc +++ b/test/decompiler/reference/levels/common/nav-enemy_REF.gc @@ -3759,7 +3759,7 @@ nav-enemy-default-event-handler ) (logior! (-> obj nav flags) - (nav-control-flags bit0 display-marks bit3 bit5 bit6 bit7) + (nav-control-flags display-marks bit0 bit3 bit5 bit6 bit7) ) (set! (-> obj nav gap-event) 'jump) (dummy-26 (-> obj nav))