mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-09 22:29:36 +00:00
disp4096: now vapor lock is working
This commit is contained in:
parent
51dd5e9a25
commit
7c8eefc868
|
@ -54,46 +54,18 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
sta DRAW_PAGE
|
||||
|
||||
; Clear Page0
|
||||
lda #$00
|
||||
sta DRAW_PAGE
|
||||
jsr clear_gr
|
||||
|
||||
; draw border line
|
||||
|
||||
; lda #$55
|
||||
; ldy #38
|
||||
; jsr hline
|
||||
; lda #$00
|
||||
; sta DRAW_PAGE
|
||||
; jsr clear_gr
|
||||
|
||||
; Clear Page1
|
||||
lda #$4
|
||||
sta DRAW_PAGE
|
||||
lda #$0
|
||||
jsr clear_gr
|
||||
|
||||
|
||||
;==================
|
||||
; Draw Blue Border on screen
|
||||
;==================
|
||||
; F -> 7 -> 6 -> 2
|
||||
|
||||
; lda #$0
|
||||
; sta DRAW_PAGE
|
||||
; lda #$6f
|
||||
; ldy #0
|
||||
; jsr hline
|
||||
; lda #$72
|
||||
; ldy #38
|
||||
; jsr hline
|
||||
|
||||
|
||||
; lda #$4
|
||||
; sta DRAW_PAGE
|
||||
; lda #$27
|
||||
; ldy #0
|
||||
; jsr hline
|
||||
; lda #$f6
|
||||
; ldy #38
|
||||
; jsr hline
|
||||
; lda #$0
|
||||
; jsr clear_gr
|
||||
|
||||
|
||||
|
||||
|
||||
;=============================
|
||||
; Load graphic page0
|
||||
|
@ -101,7 +73,7 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
lda #$0c
|
||||
sta BASH
|
||||
lda #$00
|
||||
sta BASL ; load image to page0 $400
|
||||
sta BASL ; load image to $c00
|
||||
|
||||
lda #>(katahdin_low)
|
||||
sta GBASH
|
||||
|
@ -109,13 +81,13 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
sta GBASL
|
||||
jsr load_rle_gr
|
||||
|
||||
lda #0
|
||||
lda #4
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr gr_copy_to_current
|
||||
jsr gr_copy_to_current ; copy to page1
|
||||
|
||||
; GR part
|
||||
bit PAGE0
|
||||
bit PAGE1
|
||||
bit LORES ; 4
|
||||
bit SET_GR ; 4
|
||||
bit FULLGR ; 4
|
||||
|
@ -129,7 +101,7 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
lda #$0c
|
||||
sta BASH
|
||||
lda #$00
|
||||
sta BASL ; load image to page0 $400
|
||||
sta BASL ; load image to $c00
|
||||
|
||||
lda #>(katahdin_high)
|
||||
sta GBASH
|
||||
|
@ -137,17 +109,32 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
sta GBASL
|
||||
jsr load_rle_gr
|
||||
|
||||
lda #4
|
||||
lda #0
|
||||
sta DRAW_PAGE
|
||||
|
||||
jsr gr_copy_to_current
|
||||
|
||||
; GR part
|
||||
bit PAGE1
|
||||
bit PAGE0
|
||||
|
||||
jsr wait_until_keypressed
|
||||
|
||||
|
||||
;==============================
|
||||
; setup graphics for vapor lock
|
||||
;==============================
|
||||
|
||||
; Clear Page0
|
||||
lda #$0
|
||||
sta DRAW_PAGE
|
||||
lda #$44
|
||||
jsr clear_gr
|
||||
|
||||
; Make screen half green
|
||||
lda #$11
|
||||
ldy #24
|
||||
jsr clear_page_loop
|
||||
|
||||
|
||||
;=====================================================
|
||||
; attempt vapor lock
|
||||
|
@ -168,7 +155,7 @@ WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
|
|||
; the line (max 3 repeats in that case)
|
||||
|
||||
vapor_lock_loop: ; first make sure we have all zeroes
|
||||
LDA #$00
|
||||
LDA #$11
|
||||
zxloop:
|
||||
LDX #$04
|
||||
wiloop:
|
||||
|
@ -177,7 +164,7 @@ wiloop:
|
|||
DEX
|
||||
BNE wiloop
|
||||
|
||||
LDA #$72 ; now look for our border color (4 times)
|
||||
LDA #$44 ; now look for our border color (4 times)
|
||||
zloop:
|
||||
LDX #$04
|
||||
qloop:
|
||||
|
@ -186,10 +173,9 @@ qloop:
|
|||
DEX
|
||||
BNE qloop
|
||||
|
||||
; found first line of low-res grey, need to kill time
|
||||
; until we can enter at top of screen
|
||||
; so we want roughly 10 lines * 4 = 40*65 = 2600+4550-65
|
||||
; +4550 - 65 (for the scanline we missed) = 7085 - 12 = 7073
|
||||
; found first line of black after green, at up to line 26 on screen
|
||||
; so we want roughly 22 lines * 4 = 88*65 = 5720 + 4550 = 10270
|
||||
; - 65 (for the scanline we missed) = 10205 - 12 = 10193
|
||||
|
||||
|
||||
; GR part
|
||||
|
@ -197,16 +183,11 @@ qloop:
|
|||
bit SET_GR ; 4
|
||||
bit FULLGR ; 4
|
||||
|
||||
; Try X=38 Y=52 cycles=10193
|
||||
|
||||
; want 7073
|
||||
; Try X=26 Y=52 cycles=7073
|
||||
|
||||
lda #0 ; 2
|
||||
lda #0 ; 2
|
||||
|
||||
ldy #52 ; 2
|
||||
ldy #52 ; 2
|
||||
loopA:
|
||||
ldx #26 ; 2
|
||||
ldx #38 ; 2
|
||||
loopB:
|
||||
dex ; 2
|
||||
bne loopB ; 2nt/3
|
||||
|
@ -264,9 +245,7 @@ page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
|
|||
;======================================================
|
||||
; We have 4550 cycles in the vblank, use them wisely
|
||||
;======================================================
|
||||
; scroll_the_text should be 4550+1 -2 - 13 -13 = 4523
|
||||
; rasterbars should be 4550+1 -2 - 13 -18 = 4518
|
||||
; do_nothing should be 4550+1 -2 - 13 -19 = 4517
|
||||
; do_nothing should be 4550+1 -2-9= 4540
|
||||
|
||||
jsr do_nothing ; 6
|
||||
jmp display_loop ; 3
|
||||
|
@ -276,13 +255,15 @@ page1_loop: ; delay 115+(7 loop)+4 (bit)+4(extra)
|
|||
;=================================
|
||||
; do nothing
|
||||
;=================================
|
||||
; and take 4517-6 = 4511 cycles to do it
|
||||
; and take 4540-6 = 4534 cycles to do it
|
||||
do_nothing:
|
||||
; Try X=7 Y=110 cycles=4511
|
||||
; Try X=29 Y=30 cycles=4531 R3
|
||||
|
||||
ldy #110 ; 2
|
||||
lda TEMP ; 3
|
||||
|
||||
ldy #30 ; 2
|
||||
loop1:
|
||||
ldx #7 ; 2
|
||||
ldx #29 ; 2
|
||||
loop2:
|
||||
dex ; 2
|
||||
bne loop2 ; 2nt/3
|
||||
|
@ -330,13 +311,6 @@ clear_page_loop:
|
|||
bpl clear_page_loop
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
gr_offsets:
|
||||
.word $400,$480,$500,$580,$600,$680,$700,$780
|
||||
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
|
||||
|
|
|
@ -1,206 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <png.h>
|
||||
|
||||
|
||||
static int convert_color(int color) {
|
||||
|
||||
int c=0;
|
||||
|
||||
switch(color) {
|
||||
case 0x000000: c=0; break; /* black */
|
||||
case 0xe31e60: c=1; break; /* magenta */
|
||||
case 0x604ebd: c=2; break; /* dark blue */
|
||||
case 0xff44fd: c=3; break; /* purple */
|
||||
case 0x00a360: c=4; break; /* dark green */
|
||||
case 0x9c9c9c: c=5; break; /* grey 1 */
|
||||
case 0x14cffd: c=6; break; /* medium blue */
|
||||
case 0xd0c3ff: c=7; break; /* light blue */
|
||||
case 0x607203: c=8; break; /* brown */
|
||||
case 0xff6a3c: c=9; break; /* orange */
|
||||
case 0x9d9d9d: c=10; break; /* grey 2 */
|
||||
case 0xffa0d0: c=11; break; /* pink */
|
||||
case 0x14f53c: c=12; break; /* bright green */
|
||||
case 0xd0dd8d: c=13; break; /* yellow */
|
||||
case 0x72ffd0: c=14; break; /* aqua */
|
||||
case 0xffffff: c=15; break; /* white */
|
||||
default:
|
||||
printf("Unknown color %x\n",color);
|
||||
break;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* expects a PNG where the xsize is *2 */
|
||||
int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize) {
|
||||
|
||||
int x,y;
|
||||
int color;
|
||||
FILE *infile;
|
||||
int debug=0;
|
||||
unsigned char *image,*out_ptr;
|
||||
int width, height;
|
||||
int a2_color;
|
||||
|
||||
png_byte bit_depth;
|
||||
png_structp png_ptr;
|
||||
png_infop info_ptr;
|
||||
png_bytep *row_pointers;
|
||||
png_byte color_type;
|
||||
// int number_of_passes;
|
||||
|
||||
unsigned char header[8];
|
||||
|
||||
/* open file and test for it being a png */
|
||||
infile = fopen(filename, "rb");
|
||||
if (infile==NULL) {
|
||||
fprintf(stderr,"Error! Could not open %s\n",filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check the header */
|
||||
fread(header, 1, 8, infile);
|
||||
if (png_sig_cmp(header, 0, 8)) {
|
||||
fprintf(stderr,"Error! %s is not a PNG file\n",filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* initialize stuff */
|
||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
if (!png_ptr) {
|
||||
fprintf(stderr,"Error create_read_struct\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (!info_ptr) {
|
||||
fprintf(stderr,"Error png_create_info_struct\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, infile);
|
||||
png_set_sig_bytes(png_ptr, 8);
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
width = png_get_image_width(png_ptr, info_ptr);
|
||||
height = png_get_image_height(png_ptr, info_ptr);
|
||||
*xsize=width/2;
|
||||
*ysize=height;
|
||||
|
||||
color_type = png_get_color_type(png_ptr, info_ptr);
|
||||
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
|
||||
|
||||
if (debug) {
|
||||
printf("PNG: width=%d height=%d depth=%d\n",width,height,bit_depth);
|
||||
if (color_type==PNG_COLOR_TYPE_RGB) printf("Type RGB\n");
|
||||
else if (color_type==PNG_COLOR_TYPE_RGB_ALPHA) printf("Type RGBA\n");
|
||||
else if (color_type==PNG_COLOR_TYPE_PALETTE) printf("Type palette\n");
|
||||
}
|
||||
|
||||
// number_of_passes = png_set_interlace_handling(png_ptr);
|
||||
png_read_update_info(png_ptr, info_ptr);
|
||||
|
||||
row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height);
|
||||
for (y=0; y<height; y++) {
|
||||
row_pointers[y] = (png_byte*) malloc(png_get_rowbytes(png_ptr,info_ptr));
|
||||
}
|
||||
|
||||
png_read_image(png_ptr, row_pointers);
|
||||
|
||||
fclose(infile);
|
||||
|
||||
image=calloc(width*height/2,sizeof(unsigned char));
|
||||
if (image==NULL) {
|
||||
fprintf(stderr,"Memory error!\n");
|
||||
return -1;
|
||||
}
|
||||
out_ptr=image;
|
||||
|
||||
if (color_type==PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||
for(y=0;y<height;y+=2) {
|
||||
for(x=0;x<width/2;x++) {
|
||||
|
||||
/* top color */
|
||||
color= (row_pointers[y][x*2*4]<<16)+
|
||||
(row_pointers[y][x*2*4+1]<<8)+
|
||||
(row_pointers[y][x*2*4+2]);
|
||||
if (debug) {
|
||||
printf("%x ",color);
|
||||
}
|
||||
|
||||
a2_color=convert_color(color);
|
||||
|
||||
/* bottom color */
|
||||
color= (row_pointers[y+1][x*2*4]<<16)+
|
||||
(row_pointers[y+1][x*2*4+1]<<8)+
|
||||
(row_pointers[y+1][x*2*4+2]);
|
||||
if (debug) {
|
||||
printf("%x ",color);
|
||||
}
|
||||
|
||||
a2_color|=(convert_color(color)<<4);
|
||||
|
||||
*out_ptr=a2_color;
|
||||
out_ptr++;
|
||||
}
|
||||
if (debug) printf("\n");
|
||||
}
|
||||
}
|
||||
else if (color_type==PNG_COLOR_TYPE_PALETTE) {
|
||||
for(y=0;y<height;y+=2) {
|
||||
for(x=0;x<width/2;x++) {
|
||||
|
||||
/* top color */
|
||||
a2_color=row_pointers[y][x*2];
|
||||
|
||||
/* bottom color */
|
||||
color=row_pointers[y+1][x*2];
|
||||
|
||||
a2_color|=(color<<4);
|
||||
|
||||
if (debug) {
|
||||
printf("%x ",a2_color);
|
||||
}
|
||||
|
||||
*out_ptr=a2_color;
|
||||
out_ptr++;
|
||||
}
|
||||
if (debug) printf("\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Unknown color type\n");
|
||||
}
|
||||
|
||||
/* Stripe test image */
|
||||
// for(x=0;x<40;x++) for(y=0;y<40;y++) image[(y*width)+x]=y%16;
|
||||
|
||||
/*
|
||||
Addr Row /80 %40
|
||||
$400 0 0 0 0
|
||||
$428 28 16 0
|
||||
$450 50 32 0
|
||||
$480 80 2 1
|
||||
$4A8 a8 18 1
|
||||
$4D0 d0 34 1
|
||||
$500 100 3 2
|
||||
0,0 0,1 0,2....0,39 16,0 16,1 ....16,39 32,0..32,39, X X X X X X X X
|
||||
*/
|
||||
|
||||
*image_ptr=image;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
int loadpng(char *filename, unsigned char **image_ptr, int *xsize, int *ysize);
|
||||
|
Loading…
Reference in New Issue
Block a user