paul@87 | 1 | /* |
paul@87 | 2 | * VGA display-related functions. |
paul@87 | 3 | * |
paul@87 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@87 | 5 | * |
paul@87 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@87 | 7 | * it under the terms of the GNU General Public License as published by |
paul@87 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@87 | 9 | * (at your option) any later version. |
paul@87 | 10 | * |
paul@87 | 11 | * This program is distributed in the hope that it will be useful, |
paul@87 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@87 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@87 | 14 | * GNU General Public License for more details. |
paul@87 | 15 | * |
paul@87 | 16 | * You should have received a copy of the GNU General Public License |
paul@87 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@87 | 18 | */ |
paul@87 | 19 | |
paul@87 | 20 | #ifndef __VGA_DISPLAY_CPU_H__ |
paul@87 | 21 | #define __VGA_DISPLAY_CPU_H__ |
paul@87 | 22 | |
paul@87 | 23 | #include "pic32_c.h" |
paul@87 | 24 | #include "display.h" |
paul@87 | 25 | |
paul@87 | 26 | |
paul@87 | 27 | |
paul@87 | 28 | /* Display configuration type. */ |
paul@87 | 29 | |
paul@87 | 30 | typedef struct |
paul@87 | 31 | { |
paul@87 | 32 | /* Current display state handler. */ |
paul@87 | 33 | |
paul@87 | 34 | void (*state_handler)(); |
paul@87 | 35 | |
paul@87 | 36 | /* Transfer properties. */ |
paul@87 | 37 | |
paul@87 | 38 | int line_timer; |
paul@87 | 39 | uint32_t output; |
paul@87 | 40 | |
paul@87 | 41 | /* Horizontal and vertical sync peripherals. */ |
paul@87 | 42 | |
paul@87 | 43 | int hsync_unit, vsync_unit; |
paul@87 | 44 | |
paul@87 | 45 | /* Current scanline. */ |
paul@87 | 46 | |
paul@87 | 47 | uint32_t line; |
paul@87 | 48 | |
paul@87 | 49 | /* Pointers to pixel lines. */ |
paul@87 | 50 | |
paul@87 | 51 | uint8_t *linedata; |
paul@87 | 52 | |
paul@87 | 53 | /* General display configuration. */ |
paul@87 | 54 | |
paul@87 | 55 | display_config_t *display_config; |
paul@87 | 56 | |
paul@87 | 57 | } vga_display_t; |
paul@87 | 58 | |
paul@87 | 59 | |
paul@87 | 60 | |
paul@87 | 61 | /* Initialisation. */ |
paul@87 | 62 | |
paul@87 | 63 | void init_vga(display_config_t *display_config, int line_timer); |
paul@87 | 64 | |
paul@87 | 65 | void init_vga_with_timer(display_config_t *display_config, int line_timer); |
paul@87 | 66 | |
paul@87 | 67 | void vga_configure_sync(int hsync_unit, int vsync_unit); |
paul@87 | 68 | |
paul@87 | 69 | void vga_configure_transfer(uint32_t output); |
paul@87 | 70 | |
paul@87 | 71 | /* Interrupt handlers. */ |
paul@87 | 72 | |
paul@87 | 73 | void vga_interrupt_handler(void); |
paul@87 | 74 | void vga_transfer_interrupt_handler(void); |
paul@87 | 75 | |
paul@87 | 76 | /* Display state handlers. */ |
paul@87 | 77 | |
paul@87 | 78 | void vbp_active(void); |
paul@87 | 79 | void visible_active(void); |
paul@87 | 80 | void vfp_active(void); |
paul@87 | 81 | void vsync_active(void); |
paul@87 | 82 | |
paul@87 | 83 | /* Display operations. */ |
paul@87 | 84 | |
paul@87 | 85 | void start_visible(void); |
paul@87 | 86 | void update_visible(void); |
paul@87 | 87 | void stop_visible(void); |
paul@87 | 88 | void update_transfers(int enable); |
paul@87 | 89 | |
paul@87 | 90 | /* Vertical sync operations. */ |
paul@87 | 91 | |
paul@87 | 92 | void vsync_high(void); |
paul@87 | 93 | void vsync_low(void); |
paul@87 | 94 | |
paul@87 | 95 | #endif /* __VGA_DISPLAY_CPU_H__ */ |