home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / misc / language.asm < prev    next >
Assembly Source File  |  1990-04-17  |  58KB  |  1,595 lines

  1.     Page    58,132
  2.     Title    LANGUAGE.ASM    Language Card Routines
  3. ;******************************************************************************
  4. ;
  5. ;   Name:    LANGUAGE.ASM    Language Card Routines
  6. ;
  7. ;   Group:    Emulator
  8. ;
  9. ;   Revision:    1.00
  10. ;
  11. ;   Date:    January 30, 1988
  12. ;
  13. ;   Author:    Randy W. Spurlock
  14. ;
  15. ;******************************************************************************
  16. ;
  17. ;  Module Functional Description:
  18. ;
  19. ;        This module contains all the code for the Apple
  20. ;    language card.
  21. ;
  22. ;******************************************************************************
  23. ;
  24. ;  Changes:
  25. ;
  26. ;    DATE     REVISION                DESCRIPTION
  27. ;  --------   --------    -------------------------------------------------------
  28. ;   1/30/88    1.00    Original
  29. ;
  30. ;******************************************************************************
  31.     Page
  32. ;
  33. ;  Public Declarations
  34. ;
  35.     Public    Lang_ID         ; Langauge card ID string
  36.     Public    Lang_Init        ; Language card initialization routine
  37.     Public    Lang_Ctrl        ; Language card control routine
  38.     Public    Lang_Rd         ; Language card read routine
  39.     Public    Lang_Wrt        ; Language card write routine
  40.     Public    Lang_Mem_Rd        ; Language card memory read routine
  41.     Public    Lang_Mem_Wrt        ; Language card memory write routine
  42.     Public    Lang_Exp_Rd        ; Language card expansion read routine
  43.     Public    Lang_Exp_Wrt        ; Language card expansion write routine
  44.     Public    Lang_Data        ; Language card data segment pointers
  45. ;
  46. ;  External Declarations
  47. ;
  48.     Extrn    Slot_Address:Near    ; Get expansion slot address   (DEVICE)
  49.     Extrn    Error:Near        ; Apple emulator error routine    (APPLE)
  50.     Extrn    Exit:Near        ; Apple emulator exit routine    (APPLE)
  51.     Extrn    Read_Table:Word     ; Read memory page table     (DATA)
  52.     Extrn    Write_Table:Word    ; Write memory page table     (DATA)
  53.     Extrn    ERR_NO_MEMORY:Abs    ; Not enough memory error code     (DATA)
  54. ;
  55. ;  LOCAL Equates
  56. ;
  57. LANG_SIZE    Equ    0801h        ; Langauge card memory size (32K)
  58. ROM_SIZE    Equ    0300h        ; Size of ROM area (12K)
  59. START_PAGE    Equ    0D0h        ; Starting bank switch page address
  60. START_BANK    Equ    0D0h        ; Starting bank page address
  61. START_SEG    Equ    0E0h        ; Starting segment page address
  62. BANK_COUNT    Equ    10h        ; Number of bank switched pages (4K)
  63. MAIN_COUNT    Equ    20h        ; Number of main switched pages (8K)
  64. BANK_SIZE    Equ    1000h        ; Size of bank pages (4096 Bytes)  [4K]
  65. MAIN_SIZE    Equ    2000h        ; Size of main pages (8192 Bytes)  [8K]
  66. TOTAL_SIZE    Equ    3000h        ; Total memory size (12288 Bytes) [12K]
  67. CONTROL_MASK    Equ    0Fh        ; Language card control bits mask
  68. SHIFT_COUNT    Equ    03h        ; Paragraphs to words shift count
  69. CTRL_INIT    equ    00h        ; Language card control initialization
  70. FLAG_INIT    Equ    00h        ; Language card flag initialization
  71. WRITE_SELECT    Equ    01h        ; Language card write select ctrl. bit
  72. READ_SELECT    Equ    02h        ; Language card read select ctrl. bit
  73. SEGMENT_SELECT    Equ    04h        ; Language card segment select ctrl. bit
  74. BANK_SELECT    Equ    08h        ; Language card bank select ctrl. bit
  75. SEG_CHANGE    Equ    04h        ; Language card segment change bit
  76. BANK_CHANGE    Equ    08h        ; Language card bank change bit
  77. ROM_SLOT    Equ    8000h        ; ROM read/write slot index value
  78. ;
  79. ;  Define any include files needed
  80. ;
  81.     Include     Macros.inc    ; Include the macro definitions
  82.     Include     Equates.inc    ; Include the equate definitions
  83.     Include     Strucs.inc    ; Include the structure definitions
  84.     .286c                ; Include 80286 instructions
  85.     Page
  86. ;
  87. ;  Define the emulator code segment
  88. ;
  89. Emulate Segment Word Public 'EMULATE'   ; Emulator code segment
  90.     Assume    cs:Emulate, ds:Nothing, es:Nothing
  91.     Subttl    Lang_Init    Language Card Initialization
  92.     Page    +
  93. ;******************************************************************************
  94. ;
  95. ;    Lang_Init(RAM_Space, Slot_Number)
  96. ;
  97. ;        If ROM save area has not been allocated
  98. ;            Try to allocate memory for the ROM save area
  99. ;            If errors allocating memory
  100. ;                Set error code to not enough memory
  101. ;                Call the error routine
  102. ;                Call routine to exit the emulator
  103. ;            Endif
  104. ;            Save ROM save area segment
  105. ;            Copy ROM data to save area
  106. ;            Copy language card bank write to write table
  107. ;            Copy language card segment write to write table
  108. ;        Endif for ROM save area
  109. ;        Try to allocate memory for the language card
  110. ;        If no errors allocating memory
  111. ;            Save address of language card data area
  112. ;            Initialize the language card control byte
  113. ;            Initialize the language card flags
  114. ;        Else not enough memory available
  115. ;            Set error code to not enough memory
  116. ;            Call the error routine
  117. ;            Call routine to exit the emulator
  118. ;        Endif
  119. ;        Return to the caller
  120. ;
  121. ;    Registers on Entry:
  122. ;
  123. ;        AX    - Slot number (0 - 7)
  124. ;        DS    - 65C02 RAM space
  125. ;
  126. ;    Registers on Exit:
  127. ;
  128. ;        AX-DX - Destroyed
  129. ;        SI-DI - Destroyed
  130. ;
  131. ;******************************************************************************
  132.         Even            ; Force procedure to even address
  133. Lang_Init    Proc    Near        ; Language card initialization procedure
  134.     mov    di,ax            ; Get the language card slot number
  135.     shl    di,1            ; Convert slot number to table index
  136.     mov    ax,cs:[ROM_Save]    ; Get the ROM save area segment pointer
  137.     or    ax,ax            ; Check for ROM save area allocated
  138.     jnz    Lang_Allocate        ; Jump if area already allocated
  139.     mov    ah,ALLOCATE_MEMORY    ; Get the allocate memory function code
  140.     mov    bx,ROM_SIZE        ; Get number of paragraphs to allocate
  141.     int    DOS            ; Try to allocate the ROM save area
  142.     jnc    ROM_Copy        ; Jump if no errors allocating space
  143. Memory_Error:
  144.     mov    al,ERR_NO_MEMORY    ; Get not enough memory error code
  145.     call    Error            ; Call routine to print the error
  146.     call    Exit            ; Call routine to exit the emulator
  147. ROM_Copy:
  148.     push    di            ; Save the slot index value
  149.     mov    cs:[ROM_Save],ax    ; Save the ROM save area segment
  150.     mov    dx,es            ; Save the ES segment value
  151.     mov    es,ax            ; Setup ES to the ROM save area segment
  152.     mov    ah,START_PAGE        ; Get the starting ROM page number
  153.     xor    al,al            ; Convert page number to actual address
  154.     mov    si,ax            ; Move ROM address to SI register
  155.     xor    di,di            ; Zero the DI register value
  156.     mov    cx,ROM_SIZE        ; Get the ROM area size (Paragraphs)
  157.     shl    cx,SHIFT_COUNT        ; Convert paragraphs to words
  158.     rep    movsw            ; Save the ROM data area (12K)
  159. Table_Update:
  160.     mov    ax,cs            ; Get the current CS register value
  161.     mov    es,ax            ; Setup ES to current CS register value
  162.     lea    di,cs:[Write_Table]    ; Get the write memory table offset
  163.     add    di,START_BANK Shl 1    ; Compute bank switched starting offset
  164.     lea    ax,cs:[Lang_Bank]    ; Get address of bank switched routine
  165.     mov    cx,BANK_COUNT        ; Get number of bank switched pages
  166.     rep    stosw            ; Update the write memory address
  167.     lea    di,cs:[Write_Table]    ; Get the write memory table offset
  168.     add    di,START_SEG Shl 1    ; Compute main switched starting offset
  169.     lea    ax,cs:[Lang_Segment]    ; Get address of main switched routine
  170.     mov    cx,MAIN_COUNT        ; Get number of main switched pages
  171.     rep    stosw            ; Update the write memory address
  172.     mov    es,dx            ; Restore the ES register value
  173.     pop    di            ; Restore the slot index value
  174. Lang_Allocate:
  175.     mov    ah,ALLOCATE_MEMORY    ; Get the allocate memory function code
  176.     mov    bx,LANG_SIZE        ; Get number of paragraphs to allocate
  177.     int    DOS            ; Try to allocate language card space
  178.     jc    Memory_Error        ; Jump if errors allocating space
  179.     mov    dx,ds            ; Save 65C02 RAM space segment value
  180.     mov    ds,ax            ; Setup language segment address
  181.     mov    cs:[di + Lang_Data],ax    ; Save language card segment address
  182.     mov    ds:[Lang_Byte],CTRL_INIT; Initialize the language control byte
  183.     mov    ds:[Lang_Flag],FLAG_INIT; Initialize the language card flags
  184.     mov    ds,dx            ; Restore 65C02 RAM space segment value
  185.     ret                ; Return to the caller
  186. Lang_Init    Endp            ; End of the Lang_Init procedure
  187.     Subttl    Lang_Ctrl    Language Card Control
  188.     Page    +
  189. ;******************************************************************************
  190. ;
  191. ;    Lang_Ctrl(RAM_Space, Slot_Number)
  192. ;
  193. ;
  194. ;        Return to the caller
  195. ;
  196. ;    Registers on Entry:
  197. ;
  198. ;        AX    - Slot number (0 - 7)
  199. ;        DS    - 65C02 RAM space
  200. ;
  201. ;    Registers on Exit:
  202. ;
  203. ;        None
  204. ;
  205. ;******************************************************************************
  206.         Even            ; Force procedure to even address
  207. Lang_Ctrl    Proc    Near        ; Language card control procedure
  208.  
  209.     ret                ; Return to the caller
  210. Lang_Ctrl    Endp            ; End of the Lang_Ctrl procedure
  211.     Subttl    Lang_Rd     Language Card Read
  212.     Page    +
  213. ;******************************************************************************
  214. ;
  215. ;    Lang_Rd(Effective_Address, Slot_Index)
  216. ;
  217. ;        Save the required registers
  218. ;        Setup the language card data segment
  219. ;        Get the language card control bits (From effective address)
  220. ;        Get the current control bits value
  221. ;        Update the control bits value
  222. ;        Call the correct routine to handle the update
  223. ;        Restore the required registers
  224. ;        Return to the caller
  225. ;
  226. ;    Registers on Entry:
  227. ;
  228. ;        BP    - Slot index (Slot number * 2)
  229. ;        DS:DI - 65C02 Effective address
  230. ;
  231. ;    Registers on Exit:
  232. ;
  233. ;        AL    - Memory value
  234. ;        AH    - Destroyed
  235. ;        BP    - Destroyed
  236. ;
  237. ;******************************************************************************
  238.         Even            ; Force procedure to even address
  239. Lang_Rd     Proc    Near        ; Language card read procedure
  240.     Save    bx,es            ; Save the required registers
  241.     mov    es,cs:[bp + Lang_Data]    ; Setup the language card data segment
  242.     mov    ax,di            ; Get the effective address
  243.     and    ax,CONTROL_MASK     ; Mask off all but the control bits
  244.     mov    bx,ax            ; Move control bits to BX register
  245.     shl    bx,1            ; Convert control bits to table index
  246.     mov    ah,es:[Lang_Byte]    ; Get the current control bit values
  247.     mov    es:[Lang_Byte],al    ; Update the control bits value
  248.     call    cs:[bx + Lang_Table]    ; Call correct routine to handle update
  249. Lang_Rd_Exit:
  250.     Restore bx,es            ; Restore the required registers
  251.     ret                ; Return to the caller
  252. Lang_Rd     Endp            ; End of the Lang_Rd procedure
  253.     Subttl    Lang_Wrt    Language Card Write
  254.     Page    +
  255. ;******************************************************************************
  256. ;
  257. ;    Lang_Wrt(Effective_Address, Slot_Index, Memory_Value)
  258. ;
  259. ;        Save the required registers
  260. ;        Setup the language card data segment
  261. ;        Get the language card control bits (From effective address)
  262. ;        Get the current control bits value
  263. ;        Update the control bits value
  264. ;        Call the correct routine to handle the update
  265. ;        Restore the required registers
  266. ;        Return to the caller
  267. ;
  268. ;    Registers on Entry:
  269. ;
  270. ;        AL    - Memory value
  271. ;        BP    - Slot index (Slot number * 2)
  272. ;        DS:DI - 65C02 Effective address
  273. ;
  274. ;    Registers on Exit:
  275. ;
  276. ;        BP    - Destroyed
  277. ;
  278. ;******************************************************************************
  279.         Even            ; Force procedure to even address
  280. Lang_Wrt    Proc    Near        ; Language card write procedure
  281.     Save    ax,bx,es        ; Save the required registers
  282.     mov    es,cs:[bp + Lang_Data]    ; Setup the language card data segment
  283.     mov    ax,di            ; Get the effective address
  284.     and    ax,CONTROL_MASK     ; Mask off all but the control bits
  285.     mov    bx,ax            ; Move control bits to BX register
  286.     shl    bx,1            ; Convert control bits to table index
  287.     mov    ah,es:[Lang_Byte]    ; Get the current control bit values
  288.     mov    es:[Lang_Byte],al    ; Update the control bits value
  289.     call    cs:[bx + Lang_Table]    ; Call correct routine to handle update
  290. Lang_Wrt_Exit:
  291.     Restore ax,bx,es        ; Restore the required registers
  292.     ret                ; Return to the caller
  293. Lang_Wrt    Endp            ; End of the Lang_Wrt procedure
  294.     Subttl    Lang_Mem_Rd    Language Card Memory Read
  295.     Page    +
  296. ;******************************************************************************
  297. ;
  298. ;    Lang_Mem_Rd(Effective_Address)
  299. ;
  300. ;        Return to the caller
  301. ;
  302. ;    Registers on Entry:
  303. ;
  304. ;        DS:DI - 65C02 Effective address
  305. ;
  306. ;    Registers on Exit:
  307. ;
  308. ;        AL    - Memory value
  309. ;
  310. ;******************************************************************************
  311.         Even            ; Force procedure to even address
  312. Lang_Mem_Rd    Proc    Near        ; Language card memory read procedure
  313.     ret                ; Return to the caller
  314. Lang_Mem_Rd    Endp            ; End of the Lang_Mem_Rd procedure
  315.     Subttl    Lang_Mem_Wrt    Language Card Memory Write
  316.     Page    +
  317. ;******************************************************************************
  318. ;
  319. ;    Lang_Mem_Wrt(Effective_Address)
  320. ;
  321. ;        Return to the caller
  322. ;
  323. ;    Registers on Entry:
  324. ;
  325. ;        AL    - Memory value
  326. ;        DS:DI - 65C02 Effective address
  327. ;
  328. ;    Registers on Exit:
  329. ;
  330. ;        None
  331. ;
  332. ;******************************************************************************
  333.         Even            ; Force procedure to even address
  334. Lang_Mem_Wrt    Proc    Near        ; Language card memory write procedure
  335.     ret                ; Return to the caller
  336. Lang_Mem_Wrt    Endp            ; End of the Lang_Mem_Wrt procedure
  337.     Subttl    Lang_Exp_Rd    Language Card Expansion Read
  338.     Page    +
  339. ;******************************************************************************
  340. ;
  341. ;    Lang_Exp_Rd(Effective_Address)
  342. ;
  343. ;        Read the memory location value (Byte)
  344. ;        Return to the caller
  345. ;
  346. ;    Registers on Entry:
  347. ;
  348. ;        DS:DI - 65C02 Effective address
  349. ;
  350. ;    Registers on Exit:
  351. ;
  352. ;        AL    - Memory value
  353. ;
  354. ;******************************************************************************
  355.         Even            ; Force procedure to even address
  356. Lang_Exp_Rd    Proc    Near        ; Language card expansion read procedure
  357.     mov    al,ds:[di]        ; Read the memory location
  358.     ret                ; Return to the caller
  359. Lang_Exp_Rd    Endp            ; End of the Lang_Exp_Rd procedure
  360.     Subttl    Lang_Exp_Wrt    Language Card Expansion Write
  361.     Page    +
  362. ;******************************************************************************
  363. ;
  364. ;    Lang_Exp_Wrt(Effective_Address)
  365. ;
  366. ;        Return to the caller (Area is NOT writable)
  367. ;
  368. ;    Registers on Entry:
  369. ;
  370. ;        AL    - Memory value
  371. ;        DS:DI - 65C02 Effective address
  372. ;
  373. ;    Registers on Exit:
  374. ;
  375. ;        None
  376. ;
  377. ;******************************************************************************
  378.         Even            ; Force procedure to even address
  379. Lang_Exp_Wrt    Proc    Near        ; Language card exp. write procedure
  380.     ret                ; Return to the caller
  381. Lang_Exp_Wrt    Endp            ; End of the Lang_Exp_Wrt procedure
  382.     Subttl    Lang_Bank    Language Card Bank Write Routine
  383.     Page    +
  384. ;******************************************************************************
  385. ;
  386. ;    Lang_Bank(Effective_Address, Value)
  387. ;
  388. ;        Save the required registers
  389. ;        Get the current write slot value
  390. ;        Get the language card segment for this slot
  391. ;        If this card is currently write enabled
  392. ;            If read slot matches this write slot
  393. ;                Move value into RAM space (Effective address)
  394. ;            Endif
  395. ;            Get the current write bank offset
  396. ;            Compute the actual write address
  397. ;            Move value into language card space
  398. ;        Endif
  399. ;        Restore the required registers
  400. ;        Return to the caller
  401. ;
  402. ;    Registers on Entry:
  403. ;
  404. ;        AL    - Memory value
  405. ;        DS:DI - 65C02 Effective address
  406. ;
  407. ;    Registers on Exit:
  408. ;
  409. ;        BP    - Destroyed
  410. ;
  411. ;******************************************************************************
  412.         Even            ; Force procedure to even address
  413. Lang_Bank    Proc    Near        ; Language card bank write procedure
  414.     Save    es            ; Save the required registers
  415.     mov    bp,cs:[Write_Slot]    ; Get the current write slot index
  416.     mov    es,cs:[Lang_Data + bp]    ; Get language card segment for slot
  417.     test    es:[Lang_Flag],WRITE_ENABLE
  418.     jz    Bank_Exit        ; Jump if card is NOT write enabled
  419.     cmp    bp,cs:[Read_Slot]    ; Compare to current read slot index
  420.     jne    Update_Bank        ; Jump if slots are not the same
  421.     mov    ds:[di],al        ; Update the value in RAM space
  422. Update_Bank:
  423.     mov    bp,di            ; Get the effective address offset
  424.     sub    bp,START_BANK Shl 8    ; Compute zero-based offset value
  425.     add    bp,cs:[Write_Bank]    ; Compute the actual lang. card offset
  426.     mov    es:[bp],al        ; Update the value in language card
  427. Bank_Exit:
  428.     Restore es            ; Restore the required registers
  429.     ret                ; Return to the caller
  430. Lang_Bank    Endp            ; End of the Lang_Bank procedure
  431.     Subttl    Lang_Segment    Language Card Segment Write Routine
  432.     Page    +
  433. ;******************************************************************************
  434. ;
  435. ;    Lang_Segment(Effective_Address, Value)
  436. ;
  437. ;        Save the required registers
  438. ;        Get the current write slot value
  439. ;        Get the language card segment for this slot
  440. ;        If this card is currently write enabled
  441. ;            If read slot matches this write slot
  442. ;                Move value into RAM space (Effective address)
  443. ;            Endif
  444. ;            Get the current write segment offset
  445. ;            Compute the actual write address
  446. ;            Move value into language card space
  447. ;        Endif
  448. ;        Restore the required registers
  449. ;        Return to the caller
  450. ;
  451. ;    Registers on Entry:
  452. ;
  453. ;        AL    - Memory value
  454. ;        DS:DI - 65C02 Effective address
  455. ;
  456. ;    Registers on Exit:
  457. ;
  458. ;        BP    - Destroyed
  459. ;
  460. ;******************************************************************************
  461.         Even            ; Force procedure to even address
  462. Lang_Segment    Proc    Near        ; Language card segment write procedure
  463.     Save    es            ; Save the required registers
  464.     mov    bp,cs:[Write_Slot]    ; Get the current write slot index
  465.     mov    es,cs:[Lang_Data + bp]    ; Get language card segment for slot
  466.     test    es:[Lang_Flag],WRITE_ENABLE
  467.     jz    Segment_Exit        ; Jump if card is NOT write enabled
  468.     cmp    bp,cs:[Read_Slot]    ; Compare to current read slot index
  469.     jne    Update_Segment        ; Jump if slots are not the same
  470.     mov    ds:[di],al        ; Update the value in RAM space
  471. Update_Segment:
  472.     mov    bp,di            ; Get the effective address offset
  473.     sub    bp,START_SEG Shl 8    ; Compute zero-based offset value
  474.     add    bp,cs:[Write_Seg]    ; Compute the actual lang. card offset
  475.     mov    es:[bp],al        ; Update the value in language card
  476. Segment_Exit:
  477.     Restore es            ; Restore the required registers
  478.     ret                ; Return to the caller
  479. Lang_Segment    Endp            ; End of the Lang_Segment procedure
  480.     Subttl    Lang_0        Location C0x0h Routine
  481.     Page    +
  482. ;******************************************************************************
  483. ;
  484. ;    Lang_0(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  485. ;
  486. ;        Save the required registers
  487. ;        Clear the write enable flag
  488. ;        Set the read enable flag
  489. ;        Set read slot value to slot index
  490. ;        Compute the changed control bits
  491. ;        If bank select has changed
  492. ;            Update the bank area in RAM space
  493. ;        Endif for bank select
  494. ;        If segment select has changed
  495. ;            Update the segment area in RAM space
  496. ;        Endif for segment select
  497. ;        Restore the required registers
  498. ;        Return to the caller
  499. ;
  500. ;    Registers on Entry:
  501. ;
  502. ;        AH    - Old control bits
  503. ;        AL    - New control bits
  504. ;        BP    - Slot index (Slot number * 2)
  505. ;        DS    - 65C02 RAM space
  506. ;        ES    - Language card segment
  507. ;
  508. ;    Registers on Exit:
  509. ;
  510. ;        AX-BX - Destroyed
  511. ;
  512. ;******************************************************************************
  513.         Even            ; Force procedure to even address
  514. Lang_0        Proc    Near        ; Language card C0x0h procedure
  515.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  516.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  517.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  518.     or    ax,bx            ; Logically OR in read enable state
  519.     and    es:[Lang_Flag],Not WRITE_ENABLE
  520.     or    es:[Lang_Flag],READ_ENABLE
  521.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  522.     xor    ah,al            ; Compute the changed control bits
  523.     js    Continue_0        ; Jump if this is a read change
  524.     jz    Lang_0_Exit        ; Jump if no changes have been made
  525. Continue_0:
  526.     Save    cx,si,di,ds,es        ; Save the required registers
  527.     mov    si,ds            ; Get RAM space segment value
  528.     mov    di,es            ; Get language card segment value
  529.     mov    ds,di            ; Set DS to language card segment
  530.     mov    es,si            ; Set ES to RAM space segment
  531. Check_Bank_0:
  532.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  533.     js    Copy_Bank_0        ; Jump if this is a read change
  534.     jz    Check_Seg_0        ; Jump if no bank change is required
  535. Copy_Bank_0:
  536.     lea    si,es:[Seg_1_Bank_2]    ; Get pointer to seg. 1 bank 2 area
  537.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  538.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  539.     rep    movsw            ; Move seg. 1 bank 2 to the RAM space
  540. Check_Seg_0:
  541.     test    ah,READ_ENABLE+SEG_CHANGE
  542.     js    Copy_RAM_0        ; Jump if this is a read change
  543.     jz    Lang_0_Done        ; Jump if no segment change made
  544. Copy_RAM_0:
  545.     lea    si,es:[Seg_1_RAM]    ; Get pointer to segment 1 RAM area
  546.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  547.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  548.     rep    movsw            ; Move segment 1 to the RAM space
  549. Lang_0_Done:
  550.     Restore cx,si,di,ds,es        ; Restore the required registers
  551. Lang_0_Exit:
  552.     ret                ; Return to the caller
  553. Lang_0        Endp            ; End of the Lang_0 procedure
  554.     Subttl    Lang_1        Location C0x1h Routine
  555.     Page    +
  556. ;******************************************************************************
  557. ;
  558. ;    Lang_1(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  559. ;
  560. ;        Save the required registers
  561. ;        If previous control was write enable
  562. ;            Set the write enable flag
  563. ;            Set write slot value to slot index
  564. ;            Set write segment to segment 1
  565. ;            Set write bank to bank 2
  566. ;        Endif
  567. ;        If read enable flag is set
  568. ;            Clear the read enable flag
  569. ;            Set read slot value to ROM
  570. ;            Restore the ROM image from save area
  571. ;        Endif
  572. ;        Restore the required registers
  573. ;        Return to the caller
  574. ;
  575. ;    Registers on Entry:
  576. ;
  577. ;        AH    - Old control bits
  578. ;        AL    - New control bits
  579. ;        BP    - Slot index (Slot number * 2)
  580. ;        DS    - 65C02 RAM space
  581. ;        ES    - Language card segment
  582. ;
  583. ;    Registers on Exit:
  584. ;
  585. ;        None
  586. ;
  587. ;******************************************************************************
  588.         Even            ; Force procedure to even address
  589. Lang_1        Proc    Near        ; Language card C0x1h procedure
  590.     test    ah,WRITE_SELECT     ; Check for second write enable request
  591.     jz    Skip_1            ; Jump if NOT the second write enable
  592.     or    es:[Lang_Flag],WRITE_ENABLE
  593.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  594.     mov    cs:[Write_Seg],Seg_1_RAM
  595.     mov    cs:[Write_Bank],Seg_1_Bank_2
  596. Skip_1:
  597.     test    es:[Lang_Flag],READ_ENABLE
  598.     jz    Lang_1_Exit        ; Jump if not currently read enabled
  599.     Save    cx,si,di,ds,es        ; Save the required registers
  600.     and    es:[Lang_Flag],Not READ_ENABLE
  601.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  602.     mov    si,ds            ; Get RAM space segment value
  603.     mov    es,si            ; Set ES to RAM space segment
  604.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  605.     xor    si,si            ; Zero the source index value
  606.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  607.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  608.     rep    movsw            ; Restore the ROM to the RAM space
  609. Lang_1_Done:
  610.     Restore cx,si,di,ds,es        ; Restore the required registers
  611. Lang_1_Exit:
  612.     ret                ; Return to the caller
  613. Lang_1        Endp            ; End of the Lang_1 procedure
  614.     Subttl    Lang_2        Location C0x2h Routine
  615.     Page    +
  616. ;******************************************************************************
  617. ;
  618. ;    Lang_2(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  619. ;
  620. ;        Save the required registers
  621. ;        Clear the write enable flag
  622. ;        If read enable flag is set
  623. ;            Clear the read enable flag
  624. ;            Set read slot value to ROM
  625. ;            Restore the ROM image from save area
  626. ;        Endif
  627. ;        Restore the required registers
  628. ;        Return to the caller
  629. ;
  630. ;    Registers on Entry:
  631. ;
  632. ;        AH    - Old control bits
  633. ;        AL    - New control bits
  634. ;        BP    - Slot index (Slot number * 2)
  635. ;        DS    - 65C02 RAM space
  636. ;        ES    - Language card segment
  637. ;
  638. ;    Registers on Exit:
  639. ;
  640. ;        None
  641. ;
  642. ;******************************************************************************
  643.         Even            ; Force procedure to even address
  644. Lang_2        Proc    Near        ; Language card C0x2h procedure
  645.     and    es:[Lang_Flag],Not WRITE_ENABLE
  646.     test    es:[Lang_Flag],READ_ENABLE
  647.     jz    Lang_2_Exit        ; Jump if not currently read enabled
  648.     Save    cx,si,di,ds,es        ; Save the required registers
  649.     and    es:[Lang_Flag],Not READ_ENABLE
  650.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  651.     mov    si,ds            ; Get RAM space segment value
  652.     mov    es,si            ; Set ES to RAM space segment
  653.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  654.     xor    si,si            ; Zero the source index value
  655.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  656.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  657.     rep    movsw            ; Restore the ROM to the RAM space
  658. Lang_2_Done:
  659.     Restore cx,si,di,ds,es        ; Restore the required registers
  660. Lang_2_Exit:
  661.     ret                ; Retuen to the caller
  662. Lang_2        Endp            ; End of the Lang_2 procedure
  663.     Subttl    Lang_3        Location C0x3h Routine
  664.     Page    +
  665. ;******************************************************************************
  666. ;
  667. ;    Lang_3(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  668. ;
  669. ;        Save the required registers
  670. ;        If previous control was write enable
  671. ;            Set the write enable flag
  672. ;            Set write slot value to slot index
  673. ;            Set write segment to segment 1
  674. ;            Set write bank to bank 2
  675. ;        Endif
  676. ;        Set the read enable flag
  677. ;        Set read slot value to slot index
  678. ;        Compute the changed control bits
  679. ;        If bank select has changed
  680. ;            Update the bank area in RAM space
  681. ;        Endif for bank select
  682. ;        If segment select has changed
  683. ;            Update the segment area in RAM space
  684. ;        Endif for segment select
  685. ;        Restore the required registers
  686. ;        Return to the caller
  687. ;
  688. ;    Registers on Entry:
  689. ;
  690. ;        AH    - Old control bits
  691. ;        AL    - New control bits
  692. ;        BP    - Slot index (Slot number * 2)
  693. ;        DS    - 65C02 RAM space
  694. ;        ES    - Language card segment
  695. ;
  696. ;    Registers on Exit:
  697. ;
  698. ;        None
  699. ;
  700. ;******************************************************************************
  701.         Even            ; Force procedure to even address
  702. Lang_3        Proc    Near        ; Language card C0x3h procedure
  703.     test    ah,WRITE_SELECT     ; Check for second write enable request
  704.     jz    Skip_3            ; Jump if NOT the second write enable
  705.     or    es:[Lang_Flag],WRITE_ENABLE
  706.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  707.     mov    cs:[Write_Seg],Seg_1_RAM
  708.     mov    cs:[Write_Bank],Seg_1_Bank_2
  709. Skip_3:
  710.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  711.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  712.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  713.     or    ax,bx            ; Logically OR in read enable state
  714.     or    es:[Lang_Flag],READ_ENABLE
  715.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  716.     xor    ah,al            ; Compute the changed control bits
  717.     js    Continue_3        ; Jump if this is a read change
  718.     jz    Lang_3_Exit        ; Jump if no changes have been made
  719. Continue_3:
  720.     Save    cx,si,di,ds,es        ; Save the required registers
  721.     mov    si,ds            ; Get RAM space segment value
  722.     mov    di,es            ; Get language card segment value
  723.     mov    ds,di            ; Set DS to language card segment
  724.     mov    es,si            ; Set ES to RAM space segment
  725. Check_Bank_3:
  726.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  727.     js    Copy_Bank_3        ; Jump if this is a read change
  728.     jz    Check_Seg_3        ; Jump if no bank change is required
  729. Copy_Bank_3:
  730.     lea    si,es:[Seg_1_Bank_2]    ; Get pointer to seg. 1 bank 2 area
  731.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  732.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  733.     rep    movsw            ; Move seg. 1 bank 2 to the RAM space
  734. Check_Seg_3:
  735.     test    ah,READ_ENABLE+SEG_CHANGE
  736.     js    Copy_RAM_3        ; Jump if this is a read change
  737.     jz    Lang_3_Done        ; Jump if no segment change made
  738. Copy_RAM_3:
  739.     lea    si,es:[Seg_1_RAM]    ; Get pointer to segment 1 RAM area
  740.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  741.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  742.     rep    movsw            ; Move segment 1 to the RAM space
  743. Lang_3_Done:
  744.     Restore cx,si,di,ds,es        ; Restore the required registers
  745. Lang_3_Exit:
  746.     ret                ; Return to the caller
  747. Lang_3        Endp            ; End of the Lang_3 procedure
  748.     Subttl    Lang_4        Location C0x4h Routine
  749.     Page    +
  750. ;******************************************************************************
  751. ;
  752. ;    Lang_4(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  753. ;
  754. ;        Save the required registers
  755. ;        Clear the write enable flag
  756. ;        Set the read enable flag
  757. ;        Set read slot value to slot index
  758. ;        Compute the changed control bits
  759. ;        If bank select has changed
  760. ;            Update the bank area in RAM space
  761. ;        Endif for bank select
  762. ;        If segment select has changed
  763. ;            Update the segment area in RAM space
  764. ;        Endif for segment select
  765. ;        Restore the required registers
  766. ;        Return to the caller
  767. ;
  768. ;    Registers on Entry:
  769. ;
  770. ;        AH    - Old control bits
  771. ;        AL    - New control bits
  772. ;        BP    - Slot index (Slot number * 2)
  773. ;        DS    - 65C02 RAM space
  774. ;        ES    - Language card segment
  775. ;
  776. ;    Registers on Exit:
  777. ;
  778. ;        AX    - Destroyed
  779. ;
  780. ;******************************************************************************
  781.         Even            ; Force procedure to even address
  782. Lang_4        Proc    Near        ; Language card C0x4h procedure
  783.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  784.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  785.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  786.     or    ax,bx            ; Logically OR in read enable state
  787.     and    es:[Lang_Flag],Not WRITE_ENABLE
  788.     or    es:[Lang_Flag],READ_ENABLE
  789.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  790.     xor    ah,al            ; Compute the changed control bits
  791.     js    Continue_4        ; Jump if this is a read change
  792.     jz    Lang_4_Exit        ; Jump if no changes have been made
  793. Continue_4:
  794.     Save    cx,si,di,ds,es        ; Save the required registers
  795.     mov    si,ds            ; Get RAM space segment value
  796.     mov    di,es            ; Get language card segment value
  797.     mov    ds,di            ; Set DS to language card segment
  798.     mov    es,si            ; Set ES to RAM space segment
  799. Check_Bank_4:
  800.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  801.     js    Copy_Bank_4        ; Jump if this is a read change
  802.     jz    Check_Seg_4        ; Jump if no bank change is required
  803. Copy_Bank_4:
  804.     lea    si,es:[Seg_2_Bank_2]    ; Get pointer to seg. 2 bank 2 area
  805.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  806.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  807.     rep    movsw            ; Move seg. 2 bank 2 to the RAM space
  808. Check_Seg_4:
  809.     test    ah,READ_ENABLE+SEG_CHANGE
  810.     js    Copy_RAM_4        ; Jump if this is a read change
  811.     jz    Lang_4_Done        ; Jump if no segment change made
  812. Copy_RAM_4:
  813.     lea    si,es:[Seg_2_RAM]    ; Get pointer to segment 2 RAM area
  814.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  815.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  816.     rep    movsw            ; Move segment 2 to the RAM space
  817. Lang_4_Done:
  818.     Restore cx,si,di,ds,es        ; Restore the required registers
  819. Lang_4_Exit:
  820.     ret                ; Return to the caller
  821. Lang_4        Endp            ; End of the Lang_4 procedure
  822.     Subttl    Lang_5        Location C0x5h Routine
  823.     Page    +
  824. ;******************************************************************************
  825. ;
  826. ;    Lang_5(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  827. ;
  828. ;        Save the required registers
  829. ;        If previous control was write enable
  830. ;            Set the write enable flag
  831. ;            Set write slot value to slot index
  832. ;            Set write segment to segment 2
  833. ;            Set write bank to bank 2
  834. ;        Endif
  835. ;        If read enable flag is set
  836. ;            Clear the read enable flag
  837. ;            Set read slot value to ROM
  838. ;            Restore the ROM image from save area
  839. ;        Endif
  840. ;        Restore the required registers
  841. ;        Return to the caller
  842. ;
  843. ;    Registers on Entry:
  844. ;
  845. ;        AH    - Old control bits
  846. ;        AL    - New control bits
  847. ;        BP    - Slot index (Slot number * 2)
  848. ;        DS    - 65C02 RAM space
  849. ;        ES    - Language card segment
  850. ;
  851. ;    Registers on Exit:
  852. ;
  853. ;        None
  854. ;
  855. ;******************************************************************************
  856.         Even            ; Force procedure to even address
  857. Lang_5        Proc    Near        ; Language card C0x5h procedure
  858.     test    ah,WRITE_SELECT     ; Check for second write enable request
  859.     jz    Skip_5            ; Jump if NOT the second write enable
  860.     or    es:[Lang_Flag],WRITE_ENABLE
  861.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  862.     mov    cs:[Write_Seg],Seg_2_RAM
  863.     mov    cs:[Write_Bank],Seg_2_Bank_2
  864. Skip_5:
  865.     test    es:[Lang_Flag],READ_ENABLE
  866.     jz    Lang_5_Exit        ; Jump if not currently read enabled
  867.     Save    cx,si,di,ds,es        ; Save the required registers
  868.     and    es:[Lang_Flag],Not READ_ENABLE
  869.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  870.     mov    si,ds            ; Get RAM space segment value
  871.     mov    es,si            ; Set ES to RAM space segment
  872.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  873.     xor    si,si            ; Zero the source index value
  874.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  875.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  876.     rep    movsw            ; Restore the ROM to the RAM space
  877. Lang_5_Done:
  878.     Restore cx,si,di,ds,es        ; Restore the required registers
  879. Lang_5_Exit:
  880.     ret                ; Return to the caller
  881. Lang_5        Endp            ; End of the Lang_5 procedure
  882.     Subttl    Lang_6        Location C0x6h Routine
  883.     Page    +
  884. ;******************************************************************************
  885. ;
  886. ;    Lang_6(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  887. ;
  888. ;        Save the required registers
  889. ;        Clear the write enable flag
  890. ;        If read enable flag is set
  891. ;            Clear the read enable flag
  892. ;            Set read slot value to ROM
  893. ;            Restore the ROM image from save area
  894. ;        Endif
  895. ;        Restore the required registers
  896. ;        Return to the caller
  897. ;
  898. ;    Registers on Entry:
  899. ;
  900. ;        AH    - Old control bits
  901. ;        AL    - New control bits
  902. ;        BP    - Slot index (Slot number * 2)
  903. ;        DS    - 65C02 RAM space
  904. ;        ES    - Language card segment
  905. ;
  906. ;    Registers on Exit:
  907. ;
  908. ;        None
  909. ;
  910. ;******************************************************************************
  911.         Even            ; Force procedure to even address
  912. Lang_6        Proc    Near        ; Language card C0x6h procedure
  913.     and    es:[Lang_Flag],Not WRITE_ENABLE
  914.     test    es:[Lang_Flag],READ_ENABLE
  915.     jz    Lang_6_Exit        ; Jump if not currently read enabled
  916.     Save    cx,si,di,ds,es        ; Save the required registers
  917.     and    es:[Lang_Flag],Not READ_ENABLE
  918.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  919.     mov    si,ds            ; Get RAM space segment value
  920.     mov    es,si            ; Set ES to RAM space segment
  921.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  922.     xor    si,si            ; Zero the source index value
  923.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  924.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  925.     rep    movsw            ; Restore the ROM to the RAM space
  926. Lang_6_Done:
  927.     Restore cx,si,di,ds,es        ; Restore the required registers
  928. Lang_6_Exit:
  929.     ret                ; Retuen to the caller
  930. Lang_6        Endp            ; End of the Lang_6 procedure
  931.     Subttl    Lang_7        Location C0x7h Routine
  932.     Page    +
  933. ;******************************************************************************
  934. ;
  935. ;    Lang_7(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  936. ;
  937. ;        Save the required registers
  938. ;        If previous control was write enable
  939. ;            Set the write enable flag
  940. ;            Set write slot value to slot index
  941. ;            Set write segment to segment 2
  942. ;            Set write bank to bank 2
  943. ;        Endif
  944. ;        Set the read enable flag
  945. ;        Set read slot value to slot index
  946. ;        Compute the changed control bits
  947. ;        If bank select has changed
  948. ;            Update the bank area in RAM space
  949. ;        Endif for bank select
  950. ;        If segment select has changed
  951. ;            Update the segment area in RAM space
  952. ;        Endif for segment select
  953. ;        Restore the required registers
  954. ;        Return to the caller
  955. ;
  956. ;    Registers on Entry:
  957. ;
  958. ;        AH    - Old control bits
  959. ;        AL    - New control bits
  960. ;        BP    - Slot index (Slot number * 2)
  961. ;        DS    - 65C02 RAM space
  962. ;        ES    - Language card segment
  963. ;
  964. ;    Registers on Exit:
  965. ;
  966. ;        None
  967. ;
  968. ;******************************************************************************
  969.         Even            ; Force procedure to even address
  970. Lang_7        Proc    Near        ; Language card C0x7h procedure
  971.     test    ah,WRITE_SELECT     ; Check for second write enable request
  972.     jz    Skip_7            ; Jump if NOT the second write enable
  973.     or    es:[Lang_Flag],WRITE_ENABLE
  974.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  975.     mov    cs:[Write_Seg],Seg_2_RAM
  976.     mov    cs:[Write_Bank],Seg_2_Bank_2
  977. Skip_7:
  978.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  979.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  980.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  981.     or    ax,bx            ; Logically OR in read enable state
  982.     or    es:[Lang_Flag],READ_ENABLE
  983.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  984.     xor    ah,al            ; Compute the changed control bits
  985.     js    Continue_7        ; Jump if this is a read change
  986.     jz    Lang_7_Exit        ; Jump if no changes have been made
  987. Continue_7:
  988.     Save    cx,si,di,ds,es        ; Save the required registers
  989.     mov    si,ds            ; Get RAM space segment value
  990.     mov    di,es            ; Get language card segment value
  991.     mov    ds,di            ; Set DS to language card segment
  992.     mov    es,si            ; Set ES to RAM space segment
  993. Check_Bank_7:
  994.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  995.     js    Copy_Bank_7        ; Jump if this is a read change
  996.     jz    Check_Seg_7        ; Jump if no bank change is required
  997. Copy_Bank_7:
  998.     lea    si,es:[Seg_2_Bank_2]    ; Get pointer to seg. 2 bank 2 area
  999.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  1000.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  1001.     rep    movsw            ; Move seg. 2 bank 2 to the RAM space
  1002. Check_Seg_7:
  1003.     test    ah,READ_ENABLE+SEG_CHANGE
  1004.     js    Copy_RAM_7        ; Jump if this is a read change
  1005.     jz    Lang_7_Done        ; Jump if no segment change made
  1006. Copy_RAM_7:
  1007.     lea    si,es:[Seg_2_RAM]    ; Get pointer to segment 2 RAM area
  1008.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  1009.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  1010.     rep    movsw            ; Move segment 2 to the RAM space
  1011. Lang_7_Done:
  1012.     Restore cx,si,di,ds,es        ; Restore the required registers
  1013. Lang_7_Exit:
  1014.     ret                ; Return to the caller
  1015. Lang_7        Endp            ; End of the Lang_7 procedure
  1016.     Subttl    Lang_8        Location C0x8h Routine
  1017.     Page    +
  1018. ;******************************************************************************
  1019. ;
  1020. ;    Lang_8(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1021. ;
  1022. ;        Save the required registers
  1023. ;        Clear the write enable flag
  1024. ;        Set the read enable flag
  1025. ;        Set read slot value to slot index
  1026. ;        Compute the changed control bits
  1027. ;        If bank select has changed
  1028. ;            Update the bank area in RAM space
  1029. ;        Endif for bank select
  1030. ;        If segment select has changed
  1031. ;            Update the segment area in RAM space
  1032. ;        Endif for segment select
  1033. ;        Restore the required registers
  1034. ;        Return to the caller
  1035. ;
  1036. ;    Registers on Entry:
  1037. ;
  1038. ;        AH    - Old control bits
  1039. ;        AL    - New control bits
  1040. ;        BP    - Slot index (Slot number * 2)
  1041. ;        DS    - 65C02 RAM space
  1042. ;        ES    - Language card segment
  1043. ;
  1044. ;    Registers on Exit:
  1045. ;
  1046. ;        AX    - Destroyed
  1047. ;
  1048. ;******************************************************************************
  1049.         Even            ; Force procedure to even address
  1050. Lang_8        Proc    Near        ; Language card C0x8h procedure
  1051.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  1052.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  1053.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  1054.     or    ax,bx            ; Logically OR in read enable state
  1055.     and    es:[Lang_Flag],Not WRITE_ENABLE
  1056.     or    es:[Lang_Flag],READ_ENABLE
  1057.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  1058.     xor    ah,al            ; Compute the changed control bits
  1059.     js    Continue_8        ; Jump if this is a read change
  1060.     jz    Lang_8_Exit        ; Jump if no changes have been made
  1061. Continue_8:
  1062.     Save    cx,si,di,ds,es        ; Save the required registers
  1063.     mov    si,ds            ; Get RAM space segment value
  1064.     mov    di,es            ; Get language card segment value
  1065.     mov    ds,di            ; Set DS to language card segment
  1066.     mov    es,si            ; Set ES to RAM space segment
  1067. Check_Bank_8:
  1068.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  1069.     js    Copy_Bank_8        ; Jump if this is a read change
  1070.     jz    Check_Seg_8        ; Jump if no bank change is required
  1071. Copy_Bank_8:
  1072.     lea    si,es:[Seg_1_Bank_1]    ; Get pointer to seg. 1 bank 1 area
  1073.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  1074.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  1075.     rep    movsw            ; Move seg. 1 bank 1 to the RAM space
  1076. Check_Seg_8:
  1077.     test    ah,READ_ENABLE+SEG_CHANGE
  1078.     js    Copy_RAM_8        ; Jump if this is a read change
  1079.     jz    Lang_8_Done        ; Jump if no segment change made
  1080. Copy_RAM_8:
  1081.     lea    si,es:[Seg_1_RAM]    ; Get pointer to segment 1 RAM area
  1082.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  1083.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  1084.     rep    movsw            ; Move segment 1 to the RAM space
  1085. Lang_8_Done:
  1086.     Restore cx,si,di,ds,es        ; Restore the required registers
  1087. Lang_8_Exit:
  1088.     ret                ; Return to the caller
  1089. Lang_8        Endp            ; End of the Lang_8 procedure
  1090.     Subttl    Lang_9        Location C0x9h Routine
  1091.     Page    +
  1092. ;******************************************************************************
  1093. ;
  1094. ;    Lang_9(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1095. ;
  1096. ;        Save the required registers
  1097. ;        If previous control was write enable
  1098. ;            Set the write enable flag
  1099. ;            Set write slot value to slot index
  1100. ;            Set write segment to segment 1
  1101. ;            Set write bank to bank 1
  1102. ;        Endif
  1103. ;        If read enable flag is set
  1104. ;            Clear the read enable flag
  1105. ;            Set read slot value to ROM
  1106. ;            Restore the ROM image from save area
  1107. ;        Endif
  1108. ;        Restore the required registers
  1109. ;        Return to the caller
  1110. ;
  1111. ;    Registers on Entry:
  1112. ;
  1113. ;        AH    - Old control bits
  1114. ;        AL    - New control bits
  1115. ;        BP    - Slot index (Slot number * 2)
  1116. ;        DS    - 65C02 RAM space
  1117. ;        ES    - Language card segment
  1118. ;
  1119. ;    Registers on Exit:
  1120. ;
  1121. ;        None
  1122. ;
  1123. ;******************************************************************************
  1124.         Even            ; Force procedure to even address
  1125. Lang_9        Proc    Near        ; Language card C0x9h procedure
  1126.     test    ah,WRITE_SELECT     ; Check for second write enable request
  1127.     jz    Skip_9            ; Jump if NOT the second write enable
  1128.     or    es:[Lang_Flag],WRITE_ENABLE
  1129.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  1130.     mov    cs:[Write_Seg],Seg_1_RAM
  1131.     mov    cs:[Write_Bank],Seg_1_Bank_1
  1132. Skip_9:
  1133.     test    es:[Lang_Flag],READ_ENABLE
  1134.     jz    Lang_9_Exit        ; Jump if not currently read enabled
  1135.     Save    cx,si,di,ds,es        ; Save the required registers
  1136.     and    es:[Lang_Flag],Not READ_ENABLE
  1137.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  1138.     mov    si,ds            ; Get RAM space segment value
  1139.     mov    es,si            ; Set ES to RAM space segment
  1140.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  1141.     xor    si,si            ; Zero the source index value
  1142.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  1143.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  1144.     rep    movsw            ; Restore the ROM to the RAM space
  1145. Lang_9_Done:
  1146.     Restore cx,si,di,ds,es        ; Restore the required registers
  1147. Lang_9_Exit:
  1148.     ret                ; Return to the caller
  1149. Lang_9        Endp            ; End of the Lang_9 procedure
  1150.     Subttl    Lang_A        Location C0xAh Routine
  1151.     Page    +
  1152. ;******************************************************************************
  1153. ;
  1154. ;    Lang_A(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1155. ;
  1156. ;        Save the required registers
  1157. ;        Clear the write enable flag
  1158. ;        If read enable flag is set
  1159. ;            Clear the read enable flag
  1160. ;            Set read slot value to ROM
  1161. ;            Restore the ROM image from save area
  1162. ;        Endif
  1163. ;        Restore the required registers
  1164. ;        Return to the caller
  1165. ;
  1166. ;    Registers on Entry:
  1167. ;
  1168. ;        AH    - Old control bits
  1169. ;        AL    - New control bits
  1170. ;        BP    - Slot index (Slot number * 2)
  1171. ;        DS    - 65C02 RAM space
  1172. ;        ES    - Language card segment
  1173. ;
  1174. ;    Registers on Exit:
  1175. ;
  1176. ;        None
  1177. ;
  1178. ;******************************************************************************
  1179.         Even            ; Force procedure to even address
  1180. Lang_A        Proc    Near        ; Language card C0xAh procedure
  1181.     and    es:[Lang_Flag],Not WRITE_ENABLE
  1182.     test    es:[Lang_Flag],READ_ENABLE
  1183.     jz    Lang_A_Exit        ; Jump if not currently read enabled
  1184.     Save    cx,si,di,ds,es        ; Save the required registers
  1185.     and    es:[Lang_Flag],Not READ_ENABLE
  1186.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  1187.     mov    si,ds            ; Get RAM space segment value
  1188.     mov    es,si            ; Set ES to RAM space segment
  1189.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  1190.     xor    si,si            ; Zero the source index value
  1191.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  1192.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  1193.     rep    movsw            ; Restore the ROM to the RAM space
  1194. Lang_A_Done:
  1195.     Restore cx,si,di,ds,es        ; Restore the required registers
  1196. Lang_A_Exit:
  1197.     ret                ; Retuen to the caller
  1198. Lang_A        Endp            ; End of the Lang_A procedure
  1199.     Subttl    Lang_B        Location C0xBh Routine
  1200.     Page    +
  1201. ;******************************************************************************
  1202. ;
  1203. ;    Lang_B(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1204. ;
  1205. ;        Save the required registers
  1206. ;        If previous control was write enable
  1207. ;            Set the write enable flag
  1208. ;            Set write slot value to slot index
  1209. ;            Set write segment to segment 1
  1210. ;            Set write bank to bank 1
  1211. ;        Endif
  1212. ;        Set the read enable flag
  1213. ;        Set read slot value to slot index
  1214. ;        Compute the changed control bits
  1215. ;        If bank select has changed
  1216. ;            Update the bank area in RAM space
  1217. ;        Endif for bank select
  1218. ;        If segment select has changed
  1219. ;            Update the segment area in RAM space
  1220. ;        Endif for segment select
  1221. ;        Restore the required registers
  1222. ;        Return to the caller
  1223. ;
  1224. ;    Registers on Entry:
  1225. ;
  1226. ;        AH    - Old control bits
  1227. ;        AL    - New control bits
  1228. ;        BP    - Slot index (Slot number * 2)
  1229. ;        DS    - 65C02 RAM space
  1230. ;        ES    - Language card segment
  1231. ;
  1232. ;    Registers on Exit:
  1233. ;
  1234. ;        None
  1235. ;
  1236. ;******************************************************************************
  1237.         Even            ; Force procedure to even address
  1238. Lang_B        Proc    Near        ; Language card C0xBh procedure
  1239.     test    ah,WRITE_SELECT     ; Check for second write enable request
  1240.     jz    Skip_B            ; Jump if NOT the second write enable
  1241.     or    es:[Lang_Flag],WRITE_ENABLE
  1242.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  1243.     mov    cs:[Write_Seg],Seg_1_RAM
  1244.     mov    cs:[Write_Bank],Seg_1_Bank_1
  1245. Skip_B:
  1246.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  1247.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  1248.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  1249.     or    ax,bx            ; Logically OR in read enable state
  1250.     or    es:[Lang_Flag],READ_ENABLE
  1251.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  1252.     xor    ah,al            ; Compute the changed control bits
  1253.     js    Continue_B        ; Jump if this is a read change
  1254.     jz    Lang_B_Exit        ; Jump if no changes have been made
  1255. Continue_B:
  1256.     Save    cx,si,di,ds,es        ; Save the required registers
  1257.     mov    si,ds            ; Get RAM space segment value
  1258.     mov    di,es            ; Get language card segment value
  1259.     mov    ds,di            ; Set DS to language card segment
  1260.     mov    es,si            ; Set ES to RAM space segment
  1261. Check_Bank_B:
  1262.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  1263.     js    Copy_Bank_B        ; Jump if this is a read change
  1264.     jz    Check_Seg_B        ; Jump if no bank change is required
  1265. Copy_Bank_B:
  1266.     lea    si,es:[Seg_1_Bank_1]    ; Get pointer to seg. 1 bank 1 area
  1267.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  1268.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  1269.     rep    movsw            ; Move seg. 1 bank 1 to the RAM space
  1270. Check_Seg_B:
  1271.     test    ah,READ_ENABLE+SEG_CHANGE
  1272.     js    Copy_RAM_B        ; Jump if this is a read change
  1273.     jz    Lang_B_Done        ; Jump if no segment change made
  1274. Copy_RAM_B:
  1275.     lea    si,es:[Seg_1_RAM]    ; Get pointer to segment 1 RAM area
  1276.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  1277.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  1278.     rep    movsw            ; Move segment 1 to the RAM space
  1279. Lang_B_Done:
  1280.     Restore cx,si,di,ds,es        ; Restore the required registers
  1281. Lang_B_Exit:
  1282.     ret                ; Return to the caller
  1283. Lang_B        Endp            ; End of the Lang_B procedure
  1284.     Subttl    Lang_C        Location C0xCh Routine
  1285.     Page    +
  1286. ;******************************************************************************
  1287. ;
  1288. ;    Lang_C(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1289. ;
  1290. ;        Save the required registers
  1291. ;        Clear the write enable flag
  1292. ;        Set the read enable flag
  1293. ;        Set read slot value to slot index
  1294. ;        Compute the changed control bits
  1295. ;        If bank select has changed
  1296. ;            Update the bank area in RAM space
  1297. ;        Endif for bank select
  1298. ;        If segment select has changed
  1299. ;            Update the segment area in RAM space
  1300. ;        Endif for segment select
  1301. ;        Restore the required registers
  1302. ;        Return to the caller
  1303. ;
  1304. ;    Registers on Entry:
  1305. ;
  1306. ;        AH    - Old control bits
  1307. ;        AL    - New control bits
  1308. ;        BP    - Slot index (Slot number * 2)
  1309. ;        DS    - 65C02 RAM space
  1310. ;        ES    - Language card segment
  1311. ;
  1312. ;    Registers on Exit:
  1313. ;
  1314. ;        AX    - Destroyed
  1315. ;
  1316. ;******************************************************************************
  1317.         Even            ; Force procedure to even address
  1318. Lang_C        Proc    Near        ; Language card C0xCh procedure
  1319.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  1320.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  1321.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  1322.     or    ax,bx            ; Logically OR in read enable state
  1323.     and    es:[Lang_Flag],Not WRITE_ENABLE
  1324.     or    es:[Lang_Flag],READ_ENABLE
  1325.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  1326.     xor    ah,al            ; Compute the changed control bits
  1327.     js    Continue_C        ; Jump if this is a read change
  1328.     jz    Lang_C_Exit        ; Jump if no changes have been made
  1329. Continue_C:
  1330.     Save    cx,si,di,ds,es        ; Save the required registers
  1331.     mov    si,ds            ; Get RAM space segment value
  1332.     mov    di,es            ; Get language card segment value
  1333.     mov    ds,di            ; Set DS to language card segment
  1334.     mov    es,si            ; Set ES to RAM space segment
  1335. Check_Bank_C:
  1336.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  1337.     js    Copy_Bank_C        ; Jump if this is a read change
  1338.     jz    Check_Seg_C        ; Jump if no bank change is required
  1339. Copy_Bank_C:
  1340.     lea    si,es:[Seg_2_Bank_1]    ; Get pointer to seg. 2 bank 1 area
  1341.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  1342.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  1343.     rep    movsw            ; Move seg. 2 bank 1 to the RAM space
  1344. Check_Seg_C:
  1345.     test    ah,READ_ENABLE+SEG_CHANGE
  1346.     js    Copy_RAM_C        ; Jump if this is a read change
  1347.     jz    Lang_C_Done        ; Jump if no segment change made
  1348. Copy_RAM_C:
  1349.     lea    si,es:[Seg_2_RAM]    ; Get pointer to segment 2 RAM area
  1350.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  1351.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  1352.     rep    movsw            ; Move segment 2 to the RAM space
  1353. Lang_C_Done:
  1354.     Restore cx,si,di,ds,es        ; Restore the required registers
  1355. Lang_C_Exit:
  1356.     ret                ; Return to the caller
  1357. Lang_C        Endp            ; End of the Lang_C procedure
  1358.     Subttl    Lang_D        Location C0xDh Routine
  1359.     Page    +
  1360. ;******************************************************************************
  1361. ;
  1362. ;    Lang_D(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1363. ;
  1364. ;        Save the required registers
  1365. ;        If previous control was write enable
  1366. ;            Set the write enable flag
  1367. ;            Set write slot value to slot index
  1368. ;            Set write segment to segment 2
  1369. ;            Set write bank to bank 1
  1370. ;        Endif
  1371. ;        If read enable flag is set
  1372. ;            Clear the read enable flag
  1373. ;            Set read slot value to ROM
  1374. ;            Restore the ROM image from save area
  1375. ;        Endif
  1376. ;        Restore the required registers
  1377. ;        Return to the caller
  1378. ;
  1379. ;    Registers on Entry:
  1380. ;
  1381. ;        AH    - Old control bits
  1382. ;        AL    - New control bits
  1383. ;        BP    - Slot index (Slot number * 2)
  1384. ;        DS    - 65C02 RAM space
  1385. ;        ES    - Language card segment
  1386. ;
  1387. ;    Registers on Exit:
  1388. ;
  1389. ;        None
  1390. ;
  1391. ;******************************************************************************
  1392.         Even            ; Force procedure to even address
  1393. Lang_D        Proc    Near        ; Language card C0xDh procedure
  1394.     test    ah,WRITE_SELECT     ; Check for second write enable request
  1395.     jz    Skip_D            ; Jump if NOT the second write enable
  1396.     or    es:[Lang_Flag],WRITE_ENABLE
  1397.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  1398.     mov    cs:[Write_Seg],Seg_2_RAM
  1399.     mov    cs:[Write_Bank],Seg_2_Bank_1
  1400. Skip_D:
  1401.     test    es:[Lang_Flag],READ_ENABLE
  1402.     jz    Lang_D_Exit        ; Jump if not currently read enabled
  1403.     Save    cx,si,di,ds,es        ; Save the required registers
  1404.     and    es:[Lang_Flag],Not READ_ENABLE
  1405.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  1406.     mov    si,ds            ; Get RAM space segment value
  1407.     mov    es,si            ; Set ES to RAM space segment
  1408.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  1409.     xor    si,si            ; Zero the source index value
  1410.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  1411.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  1412.     rep    movsw            ; Restore the ROM to the RAM space
  1413. Lang_D_Done:
  1414.     Restore cx,si,di,ds,es        ; Restore the required registers
  1415. Lang_D_Exit:
  1416.     ret                ; Return to the caller
  1417. Lang_D        Endp            ; End of the Lang_D procedure
  1418.     Subttl    Lang_E        Location C0xEh Routine
  1419.     Page    +
  1420. ;******************************************************************************
  1421. ;
  1422. ;    Lang_E(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1423. ;
  1424. ;        Save the required registers
  1425. ;        Clear the write enable flag
  1426. ;        If read enable flag is set
  1427. ;            Clear the read enable flag
  1428. ;            Set read slot value to ROM
  1429. ;            Restore the ROM image from save area
  1430. ;        Endif
  1431. ;        Restore the required registers
  1432. ;        Return to the caller
  1433. ;
  1434. ;    Registers on Entry:
  1435. ;
  1436. ;        AH    - Old control bits
  1437. ;        AL    - New control bits
  1438. ;        BP    - Slot index (Slot number * 2)
  1439. ;        DS    - 65C02 RAM space
  1440. ;        ES    - Language card segment
  1441. ;
  1442. ;    Registers on Exit:
  1443. ;
  1444. ;        None
  1445. ;
  1446. ;******************************************************************************
  1447.         Even            ; Force procedure to even address
  1448. Lang_E        Proc    Near        ; Language card C0xEh procedure
  1449.     and    es:[Lang_Flag],Not WRITE_ENABLE
  1450.     test    es:[Lang_Flag],READ_ENABLE
  1451.     jz    Lang_E_Exit        ; Jump if not currently read enabled
  1452.     Save    cx,si,di,ds,es        ; Save the required registers
  1453.     and    es:[Lang_Flag],Not READ_ENABLE
  1454.     mov    cs:[Read_Slot],ROM_SLOT ; Set read slot to ROM slot value
  1455.     mov    si,ds            ; Get RAM space segment value
  1456.     mov    es,si            ; Set ES to RAM space segment
  1457.     mov    ds,cs:[ROM_Save]    ; Get ROM save area segment value
  1458.     xor    si,si            ; Zero the source index value
  1459.     mov    di,START_PAGE Shl 8    ; Set DI to the starting page offset
  1460.     mov    cx,TOTAL_SIZE Shr 1    ; Set CX to the number of words to move
  1461.     rep    movsw            ; Restore the ROM to the RAM space
  1462. Lang_E_Done:
  1463.     Restore cx,si,di,ds,es        ; Restore the required registers
  1464. Lang_E_Exit:
  1465.     ret                ; Retuen to the caller
  1466. Lang_E        Endp            ; End of the Lang_E procedure
  1467.     Subttl    Lang_F        Location C0xFh Routine
  1468.     Page    +
  1469. ;******************************************************************************
  1470. ;
  1471. ;    Lang_F(Old_Control, New_Control, RAM_Space, Lang_Segment, Slot_Index)
  1472. ;
  1473. ;        Save the required registers
  1474. ;        If previous control was write enable
  1475. ;            Set the write enable flag
  1476. ;            Set write slot value to slot index
  1477. ;            Set write segment to segment 2
  1478. ;            Set write bank to bank 1
  1479. ;        Endif
  1480. ;        Set the read enable flag
  1481. ;        Set read slot value to slot index
  1482. ;        Compute the changed control bits
  1483. ;        If bank select has changed
  1484. ;            Update the bank area in RAM space
  1485. ;        Endif for bank select
  1486. ;        If segment select has changed
  1487. ;            Update the segment area in RAM space
  1488. ;        Endif for segment select
  1489. ;        Restore the required registers
  1490. ;        Return to the caller
  1491. ;
  1492. ;    Registers on Entry:
  1493. ;
  1494. ;        AH    - Old control bits
  1495. ;        AL    - New control bits
  1496. ;        BP    - Slot index (Slot number * 2)
  1497. ;        DS    - 65C02 RAM space
  1498. ;        ES    - Language card segment
  1499. ;
  1500. ;    Registers on Exit:
  1501. ;
  1502. ;        None
  1503. ;
  1504. ;******************************************************************************
  1505.         Even            ; Force procedure to even address
  1506. Lang_F        Proc    Near        ; Language card C0xFh procedure
  1507.     test    ah,WRITE_SELECT     ; Check for second write enable request
  1508.     jz    Skip_F            ; Jump if NOT the second write enable
  1509.     or    es:[Lang_Flag],WRITE_ENABLE
  1510.     mov    cs:[Write_Slot],bp    ; Set write slot to slot index
  1511.     mov    cs:[Write_Seg],Seg_2_RAM
  1512.     mov    cs:[Write_Bank],Seg_2_Bank_1
  1513. Skip_F:
  1514.     mov    bh,es:[Lang_Flag]    ; Get the current language card flags
  1515.     and    bh,READ_ENABLE        ; Mask off all but the read enable bit
  1516.     mov    bl,READ_ENABLE        ; Get new read enable bit state
  1517.     or    ax,bx            ; Logically OR in read enable state
  1518.     or    es:[Lang_Flag],READ_ENABLE
  1519.     mov    cs:[Read_Slot],bp    ; Set read slot to slot index value
  1520.     xor    ah,al            ; Compute the changed control bits
  1521.     js    Continue_F        ; Jump if this is a read change
  1522.     jz    Lang_F_Exit        ; Jump if no changes have been made
  1523. Continue_F:
  1524.     Save    cx,si,di,ds,es        ; Save the required registers
  1525.     mov    si,ds            ; Get RAM space segment value
  1526.     mov    di,es            ; Get language card segment value
  1527.     mov    ds,di            ; Set DS to language card segment
  1528.     mov    es,si            ; Set ES to RAM space segment
  1529. Check_Bank_F:
  1530.     test    ah,READ_ENABLE+SEG_CHANGE+BANK_CHANGE
  1531.     js    Copy_Bank_F        ; Jump if this is a read change
  1532.     jz    Check_Seg_F        ; Jump if no bank change is required
  1533. Copy_Bank_F:
  1534.     lea    si,es:[Seg_2_Bank_1]    ; Get pointer to seg. 2 bank 1 area
  1535.     mov    di,START_BANK Shl 8    ; Set DI to starting bank page offset
  1536.     mov    cx,BANK_SIZE Shr 1    ; Set CX to number of words to move
  1537.     rep    movsw            ; Move seg. 2 bank 1 to the RAM space
  1538. Check_Seg_F:
  1539.     test    ah,READ_ENABLE+SEG_CHANGE
  1540.     js    Copy_RAM_F        ; Jump if this is a read change
  1541.     jz    Lang_F_Done        ; Jump if no segment change made
  1542. Copy_RAM_F:
  1543.     lea    si,es:[Seg_2_RAM]    ; Get pointer to segment 2 RAM area
  1544.     mov    di,START_SEG Shl 8    ; Set DI to starting segment page offset
  1545.     mov    cx,MAIN_SIZE Shr 1    ; Set CX to number of words to move
  1546.     rep    movsw            ; Move segment 2 to the RAM space
  1547. Lang_F_Done:
  1548.     Restore cx,si,di,ds,es        ; Restore the required registers
  1549. Lang_F_Exit:
  1550.     ret                ; Return to the caller
  1551. Lang_F        Endp            ; End of the Lang_F procedure
  1552. ;******************************************************************************
  1553. ;
  1554. ;    Define the language card data areas
  1555. ;
  1556. ;******************************************************************************
  1557. Lang_Data    Equ    This Word    ; Define the langauge card pointers
  1558.         Slot_Data    <>    ; Pointers to the language data areas
  1559. ROM_Save    Equ    This Word    ; Define the ROM save area pointer
  1560.         Dw    0000h        ; Pointer to ROM save segment
  1561. Read_Slot    Equ    This Word    ; Define the read slot pointer
  1562.         Dw    ROM_SLOT    ; Default read pointer to ROM area
  1563. Write_Slot    Equ    This Word    ; Define the write slot pointer
  1564.         Dw    0000h        ; Default write pointer to slot 0
  1565. Write_Seg    Equ    This Word    ; Define the write segment offset value
  1566.         Dw    Seg_1_RAM    ; Default offset to segment 1
  1567. Write_Bank    Equ    This Word    ; Define the write bank offset value
  1568.         Dw    Seg_1_Bank_1    ; Default offset to segment 1 bank 1
  1569. Lang_Table    Equ    This Word    ; Define the language card jump table
  1570.         Dw    Lang_0        ; Location C0x0h routine address
  1571.         Dw    Lang_1        ; Location C0x1h routine address
  1572.         Dw    Lang_2        ; Location C0x2h routine address
  1573.         Dw    Lang_3        ; Location C0x3h routine address
  1574.         Dw    Lang_4        ; Location C0x4h routine address
  1575.         Dw    Lang_5        ; Location C0x5h routine address
  1576.         Dw    Lang_6        ; Location C0x6h routine address
  1577.         Dw    Lang_7        ; Location C0x7h routine address
  1578.         Dw    Lang_8        ; Location C0x8h routine address
  1579.         Dw    Lang_9        ; Location C0x9h routine address
  1580.         Dw    Lang_A        ; Location C0xAh routine address
  1581.         Dw    Lang_B        ; Location C0xBh routine address
  1582.         Dw    Lang_C        ; Location C0xCh routine address
  1583.         Dw    Lang_D        ; Location C0xDh routine address
  1584.         Dw    Lang_E        ; Location C0xEh routine address
  1585.         Dw    Lang_F        ; Location C0xFh routine address
  1586. Lang_ID     Equ    This Byte    ; Langauge card ID string
  1587.         Db    "Langauge Card",0
  1588. ;******************************************************************************
  1589. ;
  1590. ;    Define the end of the Emulator Code Segment
  1591. ;
  1592. ;******************************************************************************
  1593. Emulate Ends
  1594.     End                ; End of the Language module
  1595.