; ASCENDANCY - Savegame Updater V1.0
;
; This little programm set up the science of your race to it's maximum!
;
; done by Capella/ESC for Genetic Dreams magazine November'95
;

ideal
model large
p386n
stack 256

assume cs:coding

segment  coding

start:          mov ax,data_
                mov ds,ax
                assume ds:data_
                mov ax,0003h
                int 10h

                mov ah,09h
                mov dx,offset begin_mess
                int 21h
                
                xor ax,ax
                int 16h
                cmp al,"1"
                je f1
                cmp al,"2"
                je f2
                cmp al,"3"
                je f3
                cmp al,"4"
                je f4
                cmp al,"5"
                je f5
                
                mov dx,offset no_file
                
                ;-------------------------------------

theend:         mov ah,09h
                int 21h
                mov ax,4c00h
                int 21h

                ;-------------------------------------

f1:             mov dx,offset file1
                jmp read_file
f2:             mov dx,offset file2
                jmp read_file
f3:             mov dx,offset file3 
                jmp read_file
f4:             mov dx,offset file4
                jmp read_file
f5:             mov dx,offset file5
                

read_file:      mov [ds:errcode],4
                
                mov ax,3d02h
                int 21h
                jc error
                mov [ds:handle],ax
                mov bx,ax

                mov cx,66
                
x3x:            push cx
                
                mov [ds:errcode],5
                
                mov ax,4200h
                mov cx,[ds:file_high]
                mov dx,[ds:file_low]
                int 21h
                jc error

                mov [ds:errcode],6
                
                mov ax,4000h
                mov bx,[ds:handle]
                mov dx,offset patch_codes
                mov cx,2
                int 21h
                jc error

                pop cx

                mov ax,[ds:file_low]
                clc
                add ax,75
                jc x1x
                mov [ds:file_low],ax

                jmp x2x

x1x:            mov [ds:file_low],ax
                inc [word ds:file_high]

x2x:            dec cx
                jnz x3x

                mov [ds:errcode],7
                
                mov ax,3e00h
                int 21h
                jc error

                mov dx,offset ok_mess
                jmp theend

error:          mov [ds:errcode2],ax
                mov si,ax
                shl si,1
                mov dx,[ds:erroroff+si]
                jmp theend

ends  coding

segment  data_

file1           db "01.sav",0
file2           db "02.sav",0
file3           db "03.sav",0
file4           db "04.sav",0
file5           db "05.sav",0

handle          dw 0

file_high       dw 0       
file_low        dw 254

patch_codes     db 7fh,7eh

                db "ESC"
errcode         db 0
errcode2        dw 0
begin_mess      db 13,10,"ASCENDANCY - Savegame Updater by Capella/Escape for "
                db 13,10,"Genetic Dreams Magazine (nov'95)",13,10
                db 10,"Press keys 1-5 for savegame to update....",13,10,"$"
no_file         db 13,10,"No Savefile choosen",13,10,"$"
ok_mess         db 13,10,"Jeppa, File is updated !!! Full technology available",13,10,10,"$"

                

erroroff        dw offset err0,offset err1,offset err2,offset err3
                dw offset err0,offset err5,offset err6

err0            db 13,10,"err0 - not used error",13,10,"$"
err1            db 13,10,"err1 - not allowed offset-code",13,10,"$"
err2            db 13,10,"err2 - file not found",13,10,"$"
err3            db 13,10,"err3 - path not found",13,10,"$"
err5            db 13,10,"err5 - no access",13,10,"$"
err6            db 13,10,"err6 - not allowed handle or file not open",13,10,"$"


ends  data_

end start


