|
| 1 | +; |
| 2 | +; FastBasic - Fast basic interpreter for the Atari 8-bit computers |
| 3 | +; Copyright (C) 2017-2019 Daniel Serpell |
| 4 | +; |
| 5 | +; This program is free software; you can redistribute it and/or modify |
| 6 | +; it under the terms of the GNU General Public License as published by |
| 7 | +; the Free Software Foundation, either version 2 of the License, or |
| 8 | +; (at your option) any later version. |
| 9 | +; |
| 10 | +; This program is distributed in the hope that it will be useful, |
| 11 | +; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +; GNU General Public License for more details. |
| 14 | +; |
| 15 | +; You should have received a copy of the GNU General Public License along |
| 16 | +; with this program. If not, see <http://www.gnu.org/licenses/> |
| 17 | +; |
| 18 | +; In addition to the permissions in the GNU General Public License, the |
| 19 | +; authors give you unlimited permission to link the compiled version of |
| 20 | +; this file into combinations with other programs, and to distribute those |
| 21 | +; combinations without any restriction coming from the use of this file. |
| 22 | +; (The General Public License restrictions do apply in other respects; for |
| 23 | +; example, they cover modification of the file, and distribution when not |
| 24 | +; linked into a combine executable.) |
| 25 | + |
| 26 | + |
| 27 | +; PMGRAPHICS: P/M graphic setup |
| 28 | +; ----------------------------- |
| 29 | + |
| 30 | + .export PMGBASE, PMGMODE |
| 31 | + .import err_nomem |
| 32 | + .importzp array_ptr, next_instruction |
| 33 | + |
| 34 | + .include "atari.inc" |
| 35 | + |
| 36 | + .segment "RUNTIME" |
| 37 | + |
| 38 | +.proc EXE_PMGRAPHICS |
| 39 | + tax ; Disable if 0 |
| 40 | + beq disable_pm |
| 41 | + and #1 ; only two modes |
| 42 | + tax |
| 43 | + ; TODO: copied from AtBasic - optimize |
| 44 | + ldy pmgmode_tab,x ; Get mode |
| 45 | + lda mask_tab,x ; Get address mask |
| 46 | + and MEMTOP+1 |
| 47 | + clc ; Subtract to get P/M base |
| 48 | + adc mask_tab,x |
| 49 | + cmp array_ptr+1 |
| 50 | + bcs mem_ok |
| 51 | + jmp err_nomem |
| 52 | + |
| 53 | +disable_pm: |
| 54 | + txa ; Set A,X and Y to 0, used to write register values |
| 55 | + tay |
| 56 | + clc |
| 57 | +mem_ok: |
| 58 | + sta pmgbase |
| 59 | + sta PMBASE |
| 60 | + sty pmgmode |
| 61 | + |
| 62 | + lda SDMCTL |
| 63 | + and #$e3 |
| 64 | + bcc skip_pmenable |
| 65 | + ora pmg_dmactl_tab,x |
| 66 | + ldy #3 |
| 67 | +skip_pmenable: |
| 68 | + sta SDMCTL |
| 69 | + sty GRACTL |
| 70 | + tya ; bit 1 already set |
| 71 | + ora GPRIOR |
| 72 | + and #$c1 |
| 73 | + sta GPRIOR |
| 74 | + |
| 75 | + ; Reset GTIA registers (P/M position, sizes and hit) |
| 76 | + ldy #17 |
| 77 | + lda #0 |
| 78 | +: sta HPOSP0, y |
| 79 | + dey |
| 80 | + bpl :- |
| 81 | + |
| 82 | + jmp next_instruction |
| 83 | +.endproc |
| 84 | + |
| 85 | +pmgbase: |
| 86 | + .byte 0 |
| 87 | +pmgmode: |
| 88 | + .byte 0 |
| 89 | +mask_tab: |
| 90 | + .byte $fc,$f8 |
| 91 | +pmg_dmactl_tab: |
| 92 | + .byte $0c,$1c |
| 93 | +pmgmode_tab: |
| 94 | + .byte $40,$80 |
| 95 | + |
| 96 | +PMGBASE = pmgbase |
| 97 | +PMGMODE = pmgmode |
| 98 | + |
| 99 | + .include "../deftok.inc" |
| 100 | + deftoken "PMGRAPHICS" |
| 101 | + |
| 102 | +; vi:syntax=asm_ca65 |
0 commit comments