Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
rewrite implementation
Browse files Browse the repository at this point in the history
* remove date-based temp data 1~8
* rely on TSW's own process, so as to avoid the `VirtualStore` issue
* assembly code implementation of temp data saving for every move
  * opening a door
  * battle
  * altar and merchant and 2F oldman
  * using an item
  * trap
  * avoid meaningless temp data (such as no purchasing made; no key; ATK too low; fail to use an item; etc.)
* use file dialog to load/save a file
  * automatic detection of existing files and renaming
* pressing a hotkey will now activate the game window
* solve a bug when there is an active popup window, msgbox can lead to restarting the game
  • Loading branch information
Z-H-Sun authored Oct 8, 2023
1 parent 162613f commit eb4bd0c
Show file tree
Hide file tree
Showing 7 changed files with 1,549 additions and 304 deletions.
Binary file modified 1.ico
Binary file not shown.
117 changes: 117 additions & 0 deletions strings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# encoding: ASCII-8Bit
# CHN strings encoding is UTF-8

require './stringsGBK'

$isCHN = false
$str = Str::StrEN
module Str
TTSW10_TITLE_STR_ADDR = 0x88E74 + BASE_ADDRESS
APP_VERSION = '1.2'
@strlen = 0
module StrEN
STRINGS = [
'','','','','','','','','','','', # 10
'tswSaveLoad is running.
Use hotkeys to enhance the Load/Save function:
* Alt+0 = Load data from any file;
* Ctrl+Alt+0 = Save data to any file;
* Alt+Bksp = Take back the last move;
* Ctrl+Alt+Bksp = Quit.',
'',
'tswSaveLoad has stopped.',
'','','','','','',

'The following hotkey(s) cannot be registered properly:
%s
These hotkeys might be currently occupied by other processes
or reserved by system. Please close any conflicting program, or
as an advanced option, you can manually set `SL_MODIFIERS`
and `SL_HOTKEYS` in `tswSLdebug.txt`.
Nevertheless, tswSL will remain running, and other hotkeys
still remain fully functional.', # 20
'Load data from file: Current is %d+ %d
',
'Save data to file : Current is %d+ %d
',
'Take back one move : Current is %d+ %d
',
'The game\'s data storage path is %s.
A settings dialog box will pop up shortly; please set a new path there. Continue?',
'too short (< 2 bytes)', # 25
'too long (> 240 bytes)',
'The game now has an active popup child window;
please close it and then try again.',

'Inf', # -2
'.' # -1
]
end

module StrCN
STRINGS = [
'','','','','','','','','','','', # 10
'tswSaveLoad(快捷存档)已开启。
使用以下快捷键增强存档和读档的游戏体验:
* Alt+0 =读档自任意文件;
* Ctrl+Alt+0 =存档至任意文件;
* Alt+退格 =回退到上一节点;
* Ctrl+Alt+退格 =退出。',
'',
'tswSaveLoad(快捷存档)已退出。',
'','','','','','',

'无法设立以下快捷键:
%s
这些快捷键可能已被系统或其他进程占用。请关闭
这些进程以避免冲突。或者可利用高级设置,在
`tswSLdebug.txt` 中手动赋值给 `SL_MODIFIERS` 和
`SL_HOTKEYS`。', # 20
'读档自文件:当前设置为 %d+ %d
',
'存档至文件:当前设置为 %d+ %d
',
'回退上一步:当前设置为 %d+ %d
',
'当前游戏的存档路径%s。
请在接下来的设置对话框中选定一个合适的新路径。',
'过短(< 2 字节)', # 25
'过长(> 240 字节)',
'当前游戏界面存在活动的弹出式子窗口,
请将其关闭后再重试。',

'∞', # -2
'。' # -1
]
end

module_function
def utf8toWChar(string)
arr = string.unpack('U*')
@strlen = arr.size
arr.push 0 # end by \0\0
return arr.pack('S*')
end
def strlen() # last length
@strlen
end
def isCHN()
ReadProcessMemory.call_r($hPrc, TTSW10_TITLE_STR_ADDR, $buf, 32, 0)
title = $buf[0, 32]
if title.include?(APP_VERSION)
if title.include?(StrEN::APP_NAME)
$str = Str::StrEN
return ($isCHN = false)
elsif title.include?(StrCN::APP_NAME)
$str = Str::StrCN
return ($isCHN = true)
end
end
raise_r('This is not a compatible TSW game: '+title.rstrip)
end
end
21 changes: 21 additions & 0 deletions stringsGBK.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# encoding: ASCII-8Bit
# CHN strings encoding is GBK

module Str
module StrEN
APP_NAME = 'Tower of the Sorcerer'
DIALOG_FILTER_STR = "Game Data (*.dat)\0*.dat\0Temp Data (*.tmp)\0*.tmp\0All Files\0*.*\0\0"
TITLE_LOAD_STR = 'Load Data'
TITLE_SAVE_STR = 'Save Data'
MSG_LOAD_UNSUCC = 'Game not loaded - auto%02X.tmp'
MSG_SAVE_UNSUCC = 'Game not saved - autoID.tmp'
end
module StrCN
APP_NAME = '魔塔'
DIALOG_FILTER_STR = "游戏存档 (*.dat)\0*.dat\0临时存档 (*.tmp)\0*.tmp\0所有文件\0*.*\0\0"
TITLE_LOAD_STR = '读档自文件'
TITLE_SAVE_STR = '存档至文件'
MSG_LOAD_UNSUCC = '无法读取存档 - auto%02X.tmp'
MSG_SAVE_UNSUCC = '当前游戏未存档 - autoID.tmp'
end
end
Loading

0 comments on commit eb4bd0c

Please sign in to comment.